| 726 | */ |
| 727 | |
| 728 | cups_array_t * /* O - Array */ |
| 729 | cupsArrayNew3(cups_array_func_t f, /* I - Comparison function or @code NULL@ for an unsorted array */ |
| 730 | void *d, /* I - User data or @code NULL@ */ |
| 731 | cups_ahash_func_t h, /* I - Hash function or @code NULL@ for unhashed lookups */ |
| 732 | int hsize, /* I - Hash size (>= 0) */ |
| 733 | cups_acopy_func_t cf, /* I - Copy function */ |
| 734 | cups_afree_func_t ff) /* I - Free function */ |
| 735 | { |
| 736 | cups_array_t *a; /* Array */ |
| 737 | |
| 738 | |
| 739 | /* |
| 740 | * Allocate memory for the array... |
| 741 | */ |
| 742 | |
| 743 | a = calloc(1, sizeof(cups_array_t)); |
| 744 | if (!a) |
| 745 | return (NULL); |
| 746 | |
| 747 | a->compare = f; |
| 748 | a->data = d; |
| 749 | a->current = -1; |
| 750 | a->insert = -1; |
| 751 | a->num_saved = 0; |
| 752 | a->unique = 1; |
| 753 | |
| 754 | if (hsize > 0 && h) |
| 755 | { |
| 756 | a->hashfunc = h; |
| 757 | a->hashsize = hsize; |
| 758 | a->hash = malloc((size_t)hsize * sizeof(int)); |
| 759 | |
| 760 | if (!a->hash) |
| 761 | { |
| 762 | free(a); |
| 763 | return (NULL); |
| 764 | } |
| 765 | |
| 766 | memset(a->hash, -1, (size_t)hsize * sizeof(int)); |
| 767 | } |
| 768 | |
| 769 | a->copyfunc = cf; |
| 770 | a->freefunc = ff; |
| 771 | |
| 772 | return (a); |
| 773 | } |
| 774 | |
| 775 | |
| 776 | /* |
no outgoing calls
no test coverage detected