Changeset 6249 for trunk/Ohana/src/opihi/lib.data/queues.c
- Timestamp:
- Jan 29, 2006, 9:36:21 AM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/lib.data/queues.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/lib.data/queues.c
r4704 r6249 281 281 queue[0].Nlines --; 282 282 283 /* shrink queue allocation if small enough */ 283 284 NLINES_2 = MAX (16, queue[0].NLINES / 2); 284 285 if (queue[0].Nlines < NLINES_2) { … … 289 290 } 290 291 292 /* pop the first entry which for which the key matches */ 293 char *PopQueueMatch (Queue *queue, int Key, char *value) { 294 295 int i, choice, NLINES_2; 296 char *line, *test; 297 298 if (queue[0].Nlines == 0) return (NULL); 299 300 /* find the matching key */ 301 choice = -1; 302 for (i = 0; (i < queue[0].Nlines) && (choice == -1); i++) { 303 test = ChooseKey (queue[0].lines[i], Key); 304 if (test == NULL) continue; 305 if (strcmp (value, test)) continue; 306 choice = i; 307 } 308 if (choice == -1) return NULL; 309 310 line = queue[0].lines[choice]; 311 312 for (i = choice; i < queue[0].Nlines - 1; i++) { 313 queue[0].lines[i] = queue[0].lines[i+1]; 314 } 315 queue[0].Nlines --; 316 317 /* shrink queue allocation if small enough */ 318 NLINES_2 = MAX (16, queue[0].NLINES / 2); 319 if (queue[0].Nlines < NLINES_2) { 320 queue[0].NLINES = NLINES_2; 321 REALLOCATE (queue[0].lines, char *, queue[0].NLINES); 322 } 323 return (line); 324 } 325 291 326 int PrintQueue (FILE *f, Queue *queue) { 292 327
Note:
See TracChangeset
for help on using the changeset viewer.
