| | 255 | | | | | | gs_hash_name(name, hash_list, ngroups, create) | | | 256 | | | | | | char *name; | | | 257 | | | | | | GROUP_LIST_PTR hash_list; | | | 258 | | | | | | int *ngroups; | | | 259 | | | | | | int create; | | | 260 | | | | | | { | | | 261 | | | | | | char *key; | | | 262 | | | | | | | | | 263 | | | | | | int hash_index; | | | 264 | | | | | | int len = 0; | | | 265 | | | | | | int match; | | | 266 | | | | | | int relation; | | | 267 | | | | | | int sum = 0; | | | 268 | | | | | | | | | 269 | | | | | | GROUP_LIST_PTR current; | | | 270 | | | | | | GROUP_LIST_PTR listentry; | | | 271 | | | | | | GROUP_LIST_PTR prev; | | | 272 | | | | | | | | | 273 | | | | | | GROUP_STRUCT_PTR group; | | | 274 | | | | | | | | | 275 | | | | | | if (name == (char *) NULL || *name == '\0')
| | | 276 | | | | | | return( (GROUP_LIST_PTR) NULL);
| | | 277 | | | | | | | | | 278 | | | | | | | | | 279 | | | | | | key = name; | | | 280 | | | | | | while (*key != '\0') | | | 281 | | | | | | { | | | 282 | | | | | | sum += INTERVAL(MINCHAR, *key, MAXCHAR);
| | | 283 | | | | | | key++; | | | 284 | | | | | | len++; | | | 285 | | | | | | } | | | 286 | | | | | | | | | 287 | | | | | | hash_index = sum/len; | | | 288 | | | | | | hash_index = hash_index - MINCHAR;
| | | 289 | | | | | | | | | 290 | | | | | | | | | 291 | | | | | | | | | 292 | | | | | | | | | 293 | | | | | | | | | 294 | | | | | | prev = hash_list + hash_index; | | | 295 | | | | | | current = prev->next; | | | 296 | | | | | | listentry = (GROUP_LIST_PTR) NULL;
| | | 297 | | | | | | | | | 298 | | | | | | while (current != (GROUP_LIST_PTR) NULL )
| | | 299 | | | | | | { | | | 300 | | | | | | relation = strncmp(name, current->group->name, | | | 301 | | | | | | MAX(current->group->len,len));
| | | 302 | | | | | | | | | 303 | | | | | | if ( relation == 0 ) | | | 304 | | | | | | { | | | 305 | | | | | | listentry = current; | | | 306 | | | | | | break; | | | 307 | | | | | | } | | | 308 | | | | | | | | | 309 | | | | | | if (relation < 0) | | | 310 | | | | | | break; | | | 311 | | | | | | | | | 312 | | | | | | prev = current; | | | 313 | | | | | | | | | 314 | | | | | | current = current->next; | | | 315 | | | | | | } | | | 316 | | | | | | | | | 317 | | | | | | if (create != CREATE || listentry != (GROUP_LIST_PTR) NULL)
| | true | 318 | | | | | | return listentry; | | | 319 | | | | | | | | | 320 | | | | | | | | | 321 | | | | | | | | | 322 | | | | | | if ( (group = gs_struct_init(name)) == (GROUP_STRUCT_PTR) NULL)
| | | 323 | | | | | | return (GROUP_LIST_PTR) NULL;
| | | 324 | | | | | | | | | 325 | | | | | | listentry = gs_list_insert(group, prev, current); | | | 326 | | | | | | | | | 327 | | | | | | if (listentry != (GROUP_LIST_PTR) NULL)
| | | 328 | | | | | | (*ngroups)++; | | | 329 | | | | | | | | | 330 | | | | | | return(listentry); | | gs_hash_name$return->group->sgroup_reached < 1024 | 331 | | | | | | } | Problem | | gs_hash_name$return->group->sgroup_reached < 1024 |
|
| | 53 | | | | int * | | | 54 | | | | gs_realloc_int_array(nelems, maxelems, array, inc, init, caller) | | | 55 | | | | int nelems; | | | 56 | | | | int *maxelems; | | | 57 | | | | int *array; | | | 58 | | | | int inc; | | | 59 | | | | int init; | | | 60 | | | | char *caller; | | | 61 | | | | { | | | 62 | | | | int i; | | | 63 | | | | int *newarray, *newvalue; | | | 64 | | | | int oldmax; | | | 65 | | | | int *value; | | | 66 | | | | | | | 67 | | | | if (nelems <= *maxelems) | | | 68 | | | | return(array); | | | 69 | | | | | | | 70 | | | | newarray = array; | | | 71 | | | | | | | 72 | | | | oldmax = *maxelems; | | | 73 | | | | | | | 74 | | | | *maxelems += inc; | | | 75 | | | | | | | 76 | | | | if ( (newarray = (int *) PVM_ALLOC(sizeof(int) * (*maxelems), caller))
| | group->sgroup_reached < 1024 | 77 | | | | == (int *) NULL) | Problem | | group->sgroup_reached < 1024 |
| | | 78 | | | | { | | $unknown_17887741 <= 4095 | 79 | | | | fprintf(stderr, "could not allocate memory: %s\n", caller); | | $unknown_17887749 <= 4095 | 80 | | | | return(newarray); | | | 81 | | | | } | | | 82 | | | | | | | 83 | | | | | | | 84 | | | | | | | 85 | | | | if (oldmax > 0) | | | 86 | | | | BCOPY(array, newarray, oldmax*sizeof(int));
| | | 87 | | | | | | | 88 | | | | newvalue = newarray+oldmax; | | | 89 | | | | | | | 90 | | | | for (i = oldmax; i < *maxelems; i++) | | | 91 | | | | *newvalue++ = init; | | | 92 | | | | | | | 93 | | | | if (array != (int *) NULL)
| | | 94 | | | | PVM_FREE(array);
| | | 95 | | | | | | | 96 | | | | return(newarray); | | gs_realloc_int_array$return <= 4095 | 97 | | | | } | Problem | | gs_realloc_int_array$return <= 4095 |
|
|