IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 29, 2006, 9:36:21 AM (20 years ago)
Author:
eugene
Message:

adding to queue options, psched handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.data/queues.c

    r4704 r6249  
    281281  queue[0].Nlines --;
    282282
     283  /* shrink queue allocation if small enough */
    283284  NLINES_2 = MAX (16, queue[0].NLINES / 2);
    284285  if (queue[0].Nlines < NLINES_2) {
     
    289290}
    290291
     292/* pop the first entry which for which the key matches */
     293char *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
    291326int PrintQueue (FILE *f, Queue *queue) {
    292327
Note: See TracChangeset for help on using the changeset viewer.