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

Function cupsArrayRemove

cups/array.c:878–934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

876 */
877
878int /* O - 1 on success, 0 on failure */
879cupsArrayRemove(cups_array_t *a, /* I - Array */
880 void *e) /* I - Element */
881{
882 ssize_t i, /* Looping var */
883 current; /* Current element */
884 int diff; /* Difference */
885
886
887 /*
888 * Range check input...
889 */
890
891 if (!a || !e)
892 return (0);
893
894 /*
895 * See if the element is in the array...
896 */
897
898 if (!a->num_elements)
899 return (0);
900
901 current = cups_array_find(a, e, a->current, &diff);
902 if (diff)
903 return (0);
904
905 /*
906 * Yes, now remove it...
907 */
908
909 a->num_elements --;
910
911 if (a->freefunc)
912 (a->freefunc)(a->elements[current], a->data);
913
914 if (current < a->num_elements)
915 memmove(a->elements + current, a->elements + current + 1,
916 (size_t)(a->num_elements - current) * sizeof(void *));
917
918 if (current <= a->current)
919 a->current --;
920
921 if (current < a->insert)
922 a->insert --;
923 else if (current == a->insert)
924 a->insert = -1;
925
926 for (i = 0; i < a->num_saved; i ++)
927 if (current <= a->saved[i])
928 a->saved[i] --;
929
930 if (a->num_elements <= 1)
931 a->unique = 1;
932
933 return (1);
934}
935

Callers 15

clean_jobsFunction · 0.85
cupsdDeleteSubscriptionFunction · 0.85
cupsd_send_notificationFunction · 0.85
mimeDeleteFilterFunction · 0.85
mimeDeleteTypeFunction · 0.85
cupsdLogJobFunction · 0.85
cupsdNetIFFreeFunction · 0.85
cupsdDoSelectFunction · 0.85
cupsdRemoveSelectFunction · 0.85
cupsdCloseClientFunction · 0.85
cupsdReadClientFunction · 0.85
cupsdWriteClientFunction · 0.85

Calls 1

cups_array_findFunction · 0.85

Tested by 1

mainFunction · 0.68