MCPcopy Create free account
hub / github.com/OpenPrinting/cups / cupsArrayFind

Function cupsArrayFind

cups/array.c:436–522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

434 */
435
436void * /* O - Element found or @code NULL@ */
437cupsArrayFind(cups_array_t *a, /* I - Array */
438 void *e) /* I - Element */
439{
440 int current, /* Current element */
441 diff, /* Difference */
442 hash; /* Hash index */
443
444
445 /*
446 * Range check input...
447 */
448
449 if (!a || !e)
450 return (NULL);
451
452 /*
453 * See if we have any elements...
454 */
455
456 if (!a->num_elements)
457 return (NULL);
458
459 /*
460 * Yes, look for a match...
461 */
462
463 if (a->hash)
464 {
465 hash = (*(a->hashfunc))(e, a->data);
466
467 if (hash < 0 || hash >= a->hashsize)
468 {
469 current = a->current;
470 hash = -1;
471 }
472 else
473 {
474 current = a->hash[hash];
475
476 if (current < 0 || current >= a->num_elements)
477 current = a->current;
478 }
479 }
480 else
481 {
482 current = a->current;
483 hash = -1;
484 }
485
486 current = cups_array_find(a, e, current, &diff);
487 if (!diff)
488 {
489 /*
490 * Found a match! If the array does not contain unique values, find
491 * the first element that is the same...
492 */
493

Callers 15

get_serviceFunction · 0.85
do_testFunction · 0.85
with_distinct_valuesFunction · 0.85
copy_job_attributesFunction · 0.85
create_printerFunction · 0.85
filter_cbFunction · 0.85
find_jobFunction · 0.85
load_legacy_attributesFunction · 0.85
load_ppd_attributesFunction · 0.85
cupsdFindSubscriptionFunction · 0.85
mimeDeleteFilterFunction · 0.85

Calls 1

cups_array_findFunction · 0.85

Tested by 3

check_translationsFunction · 0.68
mainFunction · 0.68
load_wordsFunction · 0.68