| 1183 | } |
| 1184 | |
| 1185 | int totempg_groups_join ( |
| 1186 | void *totempg_groups_instance, |
| 1187 | const struct totempg_group *groups, |
| 1188 | size_t group_cnt) |
| 1189 | { |
| 1190 | struct totempg_group_instance *instance = (struct totempg_group_instance *)totempg_groups_instance; |
| 1191 | struct totempg_group *new_groups; |
| 1192 | int res = 0; |
| 1193 | |
| 1194 | if (totempg_threaded_mode == 1) { |
| 1195 | pthread_mutex_lock (&totempg_mutex); |
| 1196 | } |
| 1197 | |
| 1198 | new_groups = realloc (instance->groups, |
| 1199 | sizeof (struct totempg_group) * |
| 1200 | (instance->groups_cnt + group_cnt)); |
| 1201 | if (new_groups == 0) { |
| 1202 | res = -1; |
| 1203 | goto error_exit; |
| 1204 | } |
| 1205 | memcpy (&new_groups[instance->groups_cnt], |
| 1206 | groups, group_cnt * sizeof (struct totempg_group)); |
| 1207 | instance->groups = new_groups; |
| 1208 | instance->groups_cnt += group_cnt; |
| 1209 | |
| 1210 | error_exit: |
| 1211 | if (totempg_threaded_mode == 1) { |
| 1212 | pthread_mutex_unlock (&totempg_mutex); |
| 1213 | } |
| 1214 | return (res); |
| 1215 | } |
| 1216 | |
| 1217 | int totempg_groups_leave ( |
| 1218 | void *totempg_groups_instance, |