2 * This file is part of libdyn.a, the C Dynamic Object library. It
3 * contains the source code for the functions DynGet() and DynAdd().
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.
15 static int DynPut __P((DynObject obj, DynPtr el, int index));
23 fprintf(stderr, "dyn: get: bad index %d\n", num);
27 if (num >= obj->num_el) {
29 fprintf(stderr, "dyn: get: highest element is %d.\n",
35 fprintf(stderr, "dyn: get: Returning address %p + %d.\n",
36 obj->array, obj->el_size*num);
38 return (DynPtr) obj->array + obj->el_size*num;
47 ret = DynPut(obj, el, obj->num_el);
56 * WARNING! There is a reason this function is not documented in the
57 * man page. If DynPut used to mutate already existing elements,
58 * everything will go fine. If it is used to add new elements
59 * directly, however, the state within the object (such as
60 * obj->num_el) will not be updated properly and many other functions
61 * in the library will lose. Have a nice day.
71 fprintf(stderr, "dyn: put: Writing %d bytes from %p to %p + %d\n",
72 obj->el_size, el, obj->array, index*obj->el_size);
74 if ((ret = _DynResize(obj, index)) != DYN_OK)
77 (void) memmove(obj->array + index*obj->el_size, el, obj->el_size);
80 fprintf(stderr, "dyn: put: done.\n");