]> asedeno.scripts.mit.edu Git - 1ts-debian.git/blob - libdyn/dyn_create.c
tweak the control file, and note the fact
[1ts-debian.git] / libdyn / dyn_create.c
1 /*
2  * This file is part of libdyn.a, the C Dynamic Object library.  It
3  * contains the source code for the functions DynCreate() and
4  * DynDestroy().
5  *
6  * There are no restrictions on this code; however, if you make any
7  * changes, I request that you document them so that I do not get
8  * credit or blame for your modifications.
9  *
10  * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
11  * and MIT-Project Athena, 1989.
12  */
13
14 #include <stdio.h>
15
16 #include "dynP.h"
17
18 #ifndef DEFAULT_INC
19 #define DEFAULT_INC     100
20 #endif
21
22 static int default_increment = DEFAULT_INC;
23
24 DynObject DynCreate(el_size, inc)
25    int  el_size, inc;
26 {
27      DynObject obj;
28
29      obj = (DynObject) malloc(sizeof(DynObjectRec));
30      if (obj == NULL)
31           return NULL;
32
33      obj->array = (DynPtr) malloc(0);
34      obj->el_size = el_size;
35      obj->num_el = obj->size = 0;
36      obj->debug = obj->paranoid = 0;
37      obj->inc = (!! inc) ? inc : default_increment;
38
39      return obj;
40 }
41
42 int DynDestroy(obj)
43    DynObject obj;
44 {
45      free(obj->array);
46      free(obj);
47      return DYN_OK;
48 }