2 * This file is part of libdyn.a, the C Dynamic Object library. It
3 * contains the source code for the function DynDelete().
5 * There are no restrictions on this code; however, if you make any
6 * changes, I request that you document them so that I do not get
7 * credit or blame for your modifications.
9 * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
10 * and MIT-Project Athena, 1989.
18 * Checkers! Get away from that "hard disk erase" button!
19 * (Stupid dog. He almost did it to me again ...)
22 DynDelete(DynObject obj,
27 fprintf(stderr, "dyn: delete: bad index %d\n", idx);
31 if (idx >= obj->num_el) {
33 fprintf(stderr, "dyn: delete: Highest index is %d.\n",
38 if (idx == obj->num_el-1) {
41 fprintf(stderr, "dyn: delete: last element, zeroing.\n");
42 (void) memset(obj->array + idx*obj->el_size, 0, obj->el_size);
46 fprintf(stderr, "dyn: delete: last element, punting.\n");
52 "dyn: delete: copying %d bytes from %p + %d to + %d.\n",
53 obj->el_size*(obj->num_el - idx), obj->array,
54 (idx+1)*obj->el_size, idx*obj->el_size);
56 (void) memmove(obj->array + idx*obj->el_size,
57 obj->array + (idx+1)*obj->el_size,
58 obj->el_size*(obj->num_el - idx));
63 "dyn: delete: zeroing %d bytes from %p + %d\n",
64 obj->el_size, obj->array,
65 obj->el_size*(obj->num_el - 1));
66 (void) memset(obj->array + obj->el_size*(obj->num_el - 1),
74 fprintf(stderr, "dyn: delete: done.\n");