+2002-07-17 Ken Raeburn <raeburn@mit.edu>
+
+ * configure.in: Don't make a Makefile in util/dyn.
+ * krb5-config.in: Don't include "-ldyn".
+
2002-07-12 Ken Raeburn <raeburn@mit.edu>
* aclocal.m4 (KRB5_BUILD_LIBRARY_STATIC): Disable installation of
+2002-07-17 Ken Raeburn <raeburn@mit.edu>
+
+ * pre.in (DYN_DEPLIB): Removed.
+ (GSSRPC_DEPLIBS, GSSRPC_LIBS): Drop libdyn references.
+
2002-07-13 Tom Yu <tlyu@mit.edu>
* pre.in (PTY_DEPLIB): Fix to reflect always being built static.
KRB5_DEPLIB = $(TOPLIBD)/libkrb5$(DEPLIBEXT)
CRYPTO_DEPLIB = $(TOPLIBD)/libk5crypto$(DEPLIBEXT)
COM_ERR_DEPLIB = $(TOPLIBD)/libcom_err$(DEPLIBEXT)
-DYN_DEPLIB = $(TOPLIBD)/libdyn$(DEPLIBEXT)
# These are forced to use ".a" as an extension because they're never
# built shared.
KRB4COMPAT_DEPLIBS = $(KRB4_DEPLIB) $(DES425_DEPLIB) $(KRB5_BASE_DEPLIBS)
KDB5_DEPLIBS = $(KDB5_DEPLIB) $(DB_DEPLIB)
GSS_DEPLIBS = $(GSS_DEPLIB)
-GSSRPC_DEPLIBS = $(GSSRPC_DEPLIB) $(DYN_DEPLIB) $(GSS_DEPLIBS)
+GSSRPC_DEPLIBS = $(GSSRPC_DEPLIB) $(GSS_DEPLIBS)
KADM_COMM_DEPLIBS = $(GSSRPC_DEPLIBS) $(KDB5_DEPLIBS) $(GSSRPC_DEPLIBS)
KADMSRV_DEPLIBS = $(KADMSRV_DEPLIB) $(KDB5_DEPLIBS) $(KADM_COMM_DEPLIBS)
KADMCLNT_DEPLIBS = $(KADMCLNT_DEPLIB) $(KADM_COMM_DEPLIBS)
KDB5_LIBS = $(KDB5_LIB) $(DB_LIB)
GSS_LIBS = $(GSS_KRB5_LIB)
# needs fixing if ever used on Mac OS X!
-GSSRPC_LIBS = -lgssrpc -ldyn $(GSS_LIBS)
+GSSRPC_LIBS = -lgssrpc $(GSS_LIBS)
KADM_COMM_LIBS = $(GSSRPC_LIBS)
# need fixing if ever used on Mac OS X!
KADMSRV_LIBS = -lkadm5srv $(HESIOD_LIBS) $(KDB5_LIBS) $(KADM_COMM_LIBS)
K5_GEN_MAKEFILE(.)
K5_GEN_MAKEFILE(util)
K5_GEN_MAKEFILE(util/send-pr)
-K5_GEN_MAKEFILE(util/dyn, lib libobj)
K5_GEN_MAKEFILE(lib)
K5_GEN_MAKEFILE(config-files)
K5_GEN_MAKEFILE(gen-manpages)
fi
if test $library = 'kadm_common'; then
- lib_flags="$lib_flags -lgssrpc -ldyn"
+ lib_flags="$lib_flags -lgssrpc"
library=gssapi
fi
2002-07-17 Ken Raeburn <raeburn@mit.edu>
+ * Makefile.in (MY_SUBDIRS): Delete dyn.
+ * dyn: Directory and contents deleted.
+
* reconf: Create include/krb5/autoconf.stmp on success if it
didn't already exist.
thisconfigdir=./..
myfulldir=util
mydir=util
-MY_SUBDIRS=et ss profile pty dyn db2 send-pr
+MY_SUBDIRS=et ss profile pty db2 send-pr
BUILDTOP=$(REL)$(U)
MAC_SUBDIRS = profile et
+++ /dev/null
-2001-10-09 Ken Raeburn <raeburn@mit.edu>
-
- * dyn.h, dynP.h: Make prototypes unconditional. Don't define
- P().
-
-2001-04-25 Ezra Peisach <epeisach@mit.edu>
-
- * test.c: Always include stdlib.h
-
- * Makefile.in: Add lclint support.
-
- * dyn.h: Lclint annotate functions.
-
- * dyn_create.c (DynCreate): Do not assume that malloc(0) is valid
- and returns a valid pointer. Fix memory leak if malloc fails.
-
- * dyn_realloc.c (_DynResize): Turn off warning of shifting a
- signed variable.
-
- * test.c: Check the return values of all library calls.
-
-Thu Nov 9 15:31:31 2000 Ezra Peisach <epeisach@mit.edu>
-
- * dyn_create.c (DynCopy): Arguments to memcpy were reversed. Found
- while playing with lclint.
-
-2000-11-09 Ezra Peisach <epeisach@mit.edu>
-
- * Makefile.in (check-unix): Built and execture dyntest.
-
- * test.c: Include string,h, stdlib.h.
-
- * dyn_create.c, dyn_delete.c, dyn_insert.c, dyn_put.c,
- dyn_realloc.c: Cast arguments to malloc(), realloc(), memmove() to
- size_t.
-
- * dynP.h: Provide full prototypes for _DynRealloc() and _DynResize().
-
- * dyn.h: Add prototype for DynAppend.
-
-2000-06-29 Ezra Peisach <epeisach@mit.edu>
-
- * dyn_insert.c, dyn_put.c: Include string.h for memmove prototype.
-
-2000-06-28 Ezra Peisach <epeisach@mit.edu>
-
- * dyn_create.c, dyn_delete.c, dyn_insert.c, dyn_put.c: Use %p
- format for displaying pointers.
-
-2000-06-26 Ezra Peisach <epeisach@mit.edu>
-
- * dyn_realloc.c: Remove unused variable.
-
-1999-10-26 Wilfredo Sanchez <tritan@mit.edu>
-
- * Makefile.in: Clean up usage of CFLAGS, CPPFLAGS, DEFS, DEFINES,
- LOCAL_INCLUDES such that one can override CFLAGS from the command
- line without losing CPP search patchs and defines. Some associated
- Makefile cleanup.
-
-1999-01-27 Theodore Ts'o <tytso@rsts-11.mit.edu>
-
- * Makefile.in, configure.in: Move the responsibility for
- generating the Makefile in this directory to the top-level
- configure script. The local configure.in script has been
- deleted.
-
-Wed Feb 18 16:32:41 1998 Tom Yu <tlyu@mit.edu>
-
- * Makefile.in: Remove trailing slash from thisconfigdir. Fix up
- BUILDTOP for new conventions.
-
-Wed Jan 28 17:50:30 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>
-
- * configure.in, Makefile.in: Remove CopySrcHeader from
- configure.in, and move functionality to Makefile.in
-
- * Makefile.in: Define BUILDTOP and thisconfigdir in the Makefile
-
-Sat Dec 6 22:50:03 1997 Ezra Peisach <epeisach@mit.edu>
-
- * dyn_delete.c: Include <string.h>
-
-Tue Dec 31 13:02:06 1996 Ezra Peisach <epeisach@mit.edu>
-
- * configure.in, Makefile.in: Update to new library build procedure.
-
-Mon Jul 22 21:37:52 1996 Ezra Peisach <epeisach@mit.edu>
-
- * dyn.h: If __STDC__ is not defined, generate prototypes implying
- functions and not variables.
-
-Mon Jul 22 04:20:48 1996 Marc Horowitz <marc@mit.edu>
-
- * dyn_insert.c (DynInsert): what used to be #ifdef POSIX, should
- be #ifdef HAVE_MEMMOVE
-
-Tue Jul 9 19:30:40 1996 Marc Horowitz <marc@mit.edu>
-
- * configure.in (DEPLIBS): AC_SUBST() it, to hack around an
- incorrect assumption in aclocal.m4
- * Makefile.in (DONE): add rules and macros to support shared
- libraries
-
-
+++ /dev/null
-# This file is part of libdyn.a, the C Dynamic Object library. It
-# contains the Imakefile.
-#
-# There are no restrictions on this code; however, if you make any
-# changes, I request that you document them so that I do not get
-# credit or blame for your modifications.
-#
-# Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
-# and MIT-Project Athena, 1989.
-
-SRCS = dyn_create.c dyn_put.c dyn_debug.c dyn_delete.c dyn_size.c \
- dyn_append.c dyn_realloc.c dyn_paranoid.c dyn_insert.c \
- dyn_initzero.c
-OBJS = dyn_create.o dyn_put.o dyn_debug.o dyn_delete.o dyn_size.o \
- dyn_append.o dyn_realloc.o dyn_paranoid.o dyn_insert.o \
- dyn_initzero.o
-HDRS = dyn.h dynP.h
-
-DEST = libdyn.a
-
-StageLibrary($(DEST), $(OBJS))
-StageIncludes(dyn.h,)
-
-Program(test, test.o, $(DEST), $(DEST))
-
-Depend(,, $(SRCS) $(HDRS))
+++ /dev/null
-# This file is part of libdyn.a, the C Dynamic Object library. It
-# contains the Imakefile.
-#
-# There are no restrictions on this code; however, if you make any
-# changes, I request that you document them so that I do not get
-# credit or blame for your modifications.
-#
-# Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
-# and MIT-Project Athena, 1989.
-
-TOP := ../..
-include $(TOP)/config.mk/template
-
-SRCS := dyn_create.c dyn_put.c dyn_debug.c dyn_delete.c dyn_size.c \
- dyn_append.c dyn_realloc.c dyn_paranoid.c dyn_insert.c \
- dyn_initzero.c
-OBJS := dyn_create.o dyn_put.o dyn_debug.o dyn_delete.o dyn_size.o \
- dyn_append.o dyn_realloc.o dyn_paranoid.o dyn_insert.o \
- dyn_initzero.o
-HDRS := dyn.h # dynP.h
-
-CFLAGS := $(CFLAGS) $(D_POSIX)
-
-LIB := libdyn.a
-
-expand StageLibrary
-expand StageIncludes
-
-# PROG := test
-# OBJS := test.o
-# LIBS := libdyn.a
-#
-# expand Program
-#
-expand Depend
+++ /dev/null
-libdyn.a -- Release 1.0
-
-A C Dynamic Object is an array that takes care of resizing itself as
-elements are added and deleted from it. It can be of any type for
-which sizeof is defined and for which an address of a variable of that
-type can be passed to a function.
-
-To build libdyn.a, simply type "make depend all" (if you don't have
-the program makedepend, of course, leave out the "depend" part). If
-your system's bcopy() cannot handle overlapping regions, you'll need
-to write one that can. (Left as an excercise for the reader..)
-
-The library should compile and work without modification on a vast
-number of systems. It only uses 5 external functions: malloc,
-realloc, free, bcopy, and fprintf (to stderr). Of these, only bcopy
-should need to be changed for other systems (such as MS-DOS) and it
-could probably be done with a -D flag to the compiler.
-
-The test/demo program is built by "make all". This program produces
-the library's debugging output (to stderr) as well as some of its own
-output (to stdout).
-
-The library has been tested (with test.c) on a VAX VSII, VAXstation
-3100, DECstation 3100, and IBM RT all running BSD4.3 (except for the
-DECstation, which was running Ultrix V2.1).
-
-An earlier version of this library was posted to alt.sources. This
-version contains one new function (DynInsert) and slightly cleaner
-code, but no bugfixes (no bugs were found).
-
-Author: Barr3y Jaspan, Student Information Processing Board (SIPB) and
-MIT-Project Athena, bjaspan@athena.mit.edu, 1990
+++ /dev/null
-o be able to get obj->size
-o be able to get array without DynAdd (so you can just use DynPut)
-o be able to specify bzero on realloc
+++ /dev/null
-
-
-
-15 March 1990 DYN(3M)
-
-
-
-NAME
- dyn - the C Dynamic Object library
-
-
-DESCRIPTION
- A C Dynamic Object is an array that takes care of resizing
- itself as you add and delete elements from it. It can be of
- any type for which sizeof is defined and for which an
- address of a variable of that type can be passed to a func-
- tion. The library containing the functions described below
- is called _\bl_\bi_\bb_\bd_\by_\bn._\ba, and the necessary declarations to use
- them are in <_\bd_\by_\bn._\bh>.
-
- A DynObject is actually a structure that contains an array
- and a couple of integers to maintain necessary state infor-
- mation. When a Dyn function is said to operate on "the
- object" or "the array", it is operating on the array stored
- in the structure while at the same time updating internal
- state information.
-
-
-LIST OF FUNCTIONS
- DynObject DynCreate(size, increment)
- int size, increment;
-
- _\bR_\be_\bq_\bu_\bi_\br_\be_\bs: _\bs_\bi_\bz_\be and _\bi_\bn_\bc_\br_\be_\bm_\be_\bn_\bt are greater than zero.
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Creates a new DynObject that will store elements of
- size _\bs_\bi_\bz_\be and will allocate memory in blocks large enough to
- hold exactly _\bi_\bn_\bc_\br_\be_\bm_\be_\bn_\bt elements. For example, if you are
- storing 8-byte double precision numbers and _\bi_\bn_\bc_\br_\be_\bm_\be_\bn_\bt is 5,
- each 5th element you add to the object will cause it to
- request 40 more bytes (8 * 5) from the operating system. If
- _\bi_\bn_\bc_\br_\be_\bm_\be_\bn_\bt is zero, a default value is used (currently 100).
- This is the only time the programmer deals with a dynamic
- object's memory allocation.
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynCreate returns the new DynObject, or NULL if
- there is insufficient memory.
-
- int DynDestroy(obj)
- DynObject obj;
-
- _\bM_\bo_\bd_\bi_\bf_\bi_\be_\bs: obj
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Frees all memory associated with _\bo_\bb_\bj. The results
- of calling any Dyn function on a destroyed object are unde-
- fined (except for DynCreate, which resets the object).
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynDestroy returns DYN_OK.
-
-
-
-
-
- 1
-
-
-
-
-
-
-DYN(3M) 15 March 1990
-
-
-
- int DynAdd(obj, el)
- DynObject obj;
- DynPtr el;
-
- _\bM_\bo_\bd_\bi_\bf_\bi_\be_\bs: obj
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Adds the element pointed to by _\be_\bl to the object
- _\bo_\bb_\bj, resizing the object if necessary. The new element
- becomes the last element in obj's array.
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynAdd returns DYN_OK on success or DYN_NOMEM if
- there is insufficient memory.
-
- int DynInsert(obj, index, els, num)
- DynObject obj;
- DynPtr els;
- int index, num;
-
- _\bM_\bo_\bd_\bi_\bf_\bi_\be_\bs: obj
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Inserts the array of _\bn_\bu_\bm elements, pointed to by
- _\be_\bl_\bs, into the object _\bo_\bb_\bj starting at the array location
- _\bi_\bn_\bd_\be_\bx, resizing the object if necessary. Order is
- preserved; if you have the array "1 2 3 4 5" and insert "10
- 11 12" at the third position, you will have the array "1 2
- 10 11 12 3 4 5".
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynInsert returns DYN_BADINDEX if _\bi_\bn_\bd_\be_\bx is not
- between 0 and DynSize(obj); DYN_BADVALUE if _\bn_\bu_\bm is less than
- 1; DYN_NOMEM if there is insufficient memory.
-
- int DynGet(obj, index)
- DynObject obj;
- int index;
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Returns the address of the element _\bi_\bn_\bd_\be_\bx in the
- array of _\bo_\bb_\bj. This pointer can be treated as a normal array
- of the type specified to DynCreate. The order of elements
- in this array is the order in which they were added to the
- object. The returned pointer is guaranteed to be valid only
- until obj is modified.
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynGet returns NULL if _\bi_\bn_\bd_\be_\bx is larger than the
- number of elements in the array of less than zero.
-
- int DynDelete(obj, index)
- DynObject obj;
- int index;
-
- _\bM_\bo_\bd_\bi_\bf_\bi_\be_\bs: obj
-
-
-
-
-
-2
-
-
-
-
-
-
-15 March 1990 DYN(3M)
-
-
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: The element _\bi_\bn_\bd_\be_\bx is deleted from the object _\bo_\bb_\bj.
- Note that the element is actually removed permanently from
- the array. If you have the array "1 2 3 4 5" and delete the
- third element, you will have the array "1 2 4 5". The order
- of elements in not affected.
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynDelete will return DYN_OK on success or
- DYN_BADINDEX if the element _\bi_\bn_\bd_\be_\bx does not exist in the
- array or is less than zero.
-
- int DynSize(obj)
- DynObject obj;
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Returns the number of elements in the object _\bo_\bb_\bj.
-
- int DynHigh(obj)
- DynObject obj;
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Returns the index of the highest element in the
- object _\bo_\bb_\bj. In this version, DynHigh is macro that expands
- to DynSize - 1.
-
- int DynLow(obj)
- DynObject obj;
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Returns the index of the lowest element in the
- object _\bo_\bb_\bj. In this version, DynLow is macro that expands
- to 0.
-
- int DynDebug(obj, state)
- DynObject obj;
- int state;
-
- _\bM_\bo_\bd_\bi_\bf_\bi_\be_\bs: obj
-
- _\bE_\bf_\bf_\be_\bc_\bt_\bs: Sets the debugging state of _\bo_\bb_\bj to _\bs_\bt_\ba_\bt_\be and prints
- a message on stderr saying what state debugging was set to.
- Any non-zero value for _\bs_\bt_\ba_\bt_\be turns debugging ``on''. When
- debugging is on, all Dyn functions will produce (hopefully
- useful) output to stderr describing what is going on.
-
- _\bR_\be_\bt_\bu_\br_\bn_\bs: DynDebug returns DYN_OK.
-
-AUTHOR
- Barr3y Jaspan, Student Information Processing Board (SIPB)
- and MIT-Project Athena, bjaspan@athena.mit.edu
-
-
-
-
-
-
-
-
-
- 3
-
-
-
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the public header file.
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-
-/*
- * dyn.h -- header file to be included by programs linking against
- * libdyn.a.
- */
-
-#ifndef _Dyn_h
-#define _Dyn_h
-
-typedef char *DynPtr;
-typedef struct _DynObject {
- DynPtr array;
- int el_size, num_el, size, inc;
- int debug, paranoid, initzero;
-} DynObjectRec, *DynObject;
-
-/* Function macros */
-#define DynHigh(obj) (DynSize(obj) - 1)
-#define DynLow(obj) (0)
-
-/* Return status codes */
-#define DYN_OK -1000
-#define DYN_NOMEM -1001
-#define DYN_BADINDEX -1002
-#define DYN_BADVALUE -1003
-
-/*@null@*//*@only@*/ DynObject DynCreate (int el_size, int inc);
-/*@null@*//*@only@*/ DynObject DynCopy (DynObject obj);
-int DynDestroy (/*@only@*/DynObject obj), DynRelease (DynObject obj);
-int DynAdd (DynObject obj, void *el);
-int DynPut (DynObject obj, void *el, int idx);
-int DynInsert (DynObject obj, int idx, /*@observer@*/void *els, int num);
-int DynDelete (DynObject obj, int idx);
-/*@dependent@*//*@null@*/ DynPtr DynGet (DynObject obj, int num);
-/*@observer@*/ DynPtr DynArray (DynObject obj);
-int DynDebug (DynObject obj, int state);
-int DynParanoid (DynObject obj, int state);
-int DynInitzero (DynObject obj, int state);
-int DynSize (DynObject obj);
-int DynCapacity (DynObject obj);
-int DynAppend (DynObject obj, DynPtr els, int num);
-
-#undef P
-
-#endif /* _Dyn_h */
-/* DO NOT ADD ANYTHING AFTER THIS #endif */
+++ /dev/null
-.TH DYN 3 "07 December 1992"
-
-.SH NAME
-dyn \- the C Dynamic Object library
-
-.SH DESCRIPTION
-
-A C Dynamic Object is an array that takes care of resizing
-itself as you add and delete elements from it. It can be of any type
-for which sizeof is defined and for which an address of a variable of
-that type can be passed to a function. The library containing the
-functions described below is called
-.IR libdyn.a ,
-and the necessary declarations to use them are in
-.RI < dyn.h >.
-.PP
-A DynObject is actually a structure that contains an array and a
-couple of integers to maintain necessary state information. When a
-Dyn function is said to operate on "the object" or "the array", it is
-operating on the array stored in the structure while at the same time
-updating internal state information.
-
-.SH LIST OF FUNCTIONS
-.nf
-DynObject DynCreate(size, increment)
- int size, increment;
-.fi
-.PP
-.IR Requires :
-.I size
-and
-.I increment
-are greater than zero.
-.PP
-.IR Effects :
-Creates a new DynObject that will store elements of size
-.IR size .
-If
-.I increment
-is positive, the object will allocate memory in blocks large enough to
-hold exactly
-.I increment
-elements; if it is negative, the object will allocate memory by
-doubling in size each time more space is needed, starting with an
-initial size of
-.RI - increment .
-For example, if you are storing 8-byte double precision numbers and
-.I increment
-is 5, each 5th element you add to the object will cause it to request
-40 more bytes (8 * 5) from the operating system. If
-.I increment
-is -4, adding the first element causes the object to request 32 bytes
-(4 * 8); adding the fifth element requests 32 more bytes for a total
-of 8 elements; adding the ninth element requests 64 more bytes, for a
-total of 16 elements. If
-.I increment
-is zero, a default value is used (currently 100). This is the only
-time the programmer deals with a dynamic object's memory allocation.
-.PP
-.IR Returns :
-.B DynCreate
-returns the new DynObject, or NULL if there is insufficient memory.
-.PP
-.nf
-int DynDestroy(obj)
- DynObject obj;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-Frees all memory associated with
-.IR obj .
-The results of calling any Dyn function on a destroyed object are
-undefined (except for DynCreate, which resets the object).
-.PP
-.IR Returns :
-.B DynDestroy
-returns DYN_OK.
-.PP
-.nf
-int DynRelease(obj)
- DynObject obj;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-Frees the memory used to store
-.IR obj 's
-internal state, but leaves the object's array intact. This is useful
-when you want to use a DynObject to create an arbitrary sized array,
-but then do not want to deal with the DynObject abstraction or having
-to remember to free the object later.
-.nf
-int DynAdd(obj, el)
- DynObject obj;
- DynPtr el;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-Adds the element pointed to by
-.I el
-to the object
-.IR obj ,
-resizing the object if necessary.
-The new element becomes the last element in obj's array.
-.PP
-.IR Returns :
-.B DynAdd
-returns DYN_OK on success or DYN_NOMEM if there is insufficient
-memory.
-.PP
-.nf
-int DynInsert(obj, index, els, num)
- DynObject obj;
- DynPtr els;
- int index, num;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-Inserts the array of
-.I num
-elements, pointed to by
-.IR els,
-into the object
-.I obj
-starting at the array location
-.IR index ,
-resizing the object if necessary. Order is preserved; if you have the
-array "1 2 3 4 5" and insert "10 11 12" at the third position, you
-will have the array "1 2 10 11 12 3 4 5".
-.PP
-.IR Returns :
-.B DynInsert
-returns DYN_BADINDEX if
-.I index
-is not between 0 and
-.BR DynSize ( obj ) ;
-DYN_BADVALUE if
-.I num
-is less than 1; DYN_NOMEM if there is insufficient memory.
-.PP
-.nf
-int DynGet(obj, index)
- DynObject obj;
- int index;
-.fi
-.PP
-.IR Effects :
-Returns the address of the element
-.I index
-in the array of
-.IR obj .
-This pointer can be treated as a normal array of the type specified to
-.BR DynCreate .
-The order of elements in this array is the order in which they were
-added to the object. The returned pointer is guaranteed to be valid
-only until obj is modified.
-.PP
-.IR Returns :
-.B DynGet
-returns NULL if
-.I index
-is larger than the number of elements in the array of less than zero.
-.PP
-.nf
-int DynArray(obj)
- DynObject obj;
-.fi
-.PP
-.IR Effects :
-Returns the address of
-.IR obj 's
-array. This function is equivalent to
-.BR DynGet (
-.I obj
-, 0).
-.PP
-.nf
-int DynDelete(obj, index)
- DynObject obj;
- int index;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-The element
-.I index
-is deleted from the object
-.IR obj .
-Note that the element is actually removed permanently from the array.
-If you have the array "1 2 3 4 5" and delete the third element, you
-will have the array "1 2 4 5". The order of elements in not affected.
-.PP
-.IR Returns :
-.B DynDelete
-will return DYN_OK on success or DYN_BADINDEX if the element
-.I index
-does not exist in the array or is less than zero.
-.PP
-.nf
-int DynSize(obj)
- DynObject obj;
-.fi
-.PP
-.IR Effects :
-Returns the number of elements in the object
-.IR obj .
-.PP
-.nf
-int DynCapacity(obj)
- DynObject obj;
-.fi
-.PP
-.IR Effects :
-Returns the number of elements that
-.IR obj .
-can store without resizing.
-.PP
-.nf
-int DynHigh(obj)
- DynObject obj;
-.fi
-.PP
-.IR Effects :
-Returns the index of the highest element in the object
-.IR obj .
-In this version,
-.B DynHigh
-is macro that expands to
-.B DynSize
-- 1.
-.PP
-.nf
-int DynLow(obj)
- DynObject obj;
-.fi
-.PP
-.IR Effects :
-Returns the index of the lowest element in the object
-.IR obj .
-In this version,
-.B DynLow
-is macro that expands to 0.
-.PP
-.nf
-int DynParanoid(obj, state)
- DynObjectP obj;
- char state;
-.fi
-.PP
-.IR Modified :
-obj
-.OO
-.IR Effects :
-Sets the paranoid state of
-.I obj
-to
-.IR state .
-When paranoid mode is on, all data deleted from the object is erased
-with bzero.
-.PP
-.IR Returns :
-.B DynParanoid
-returns DYN_OK.
-.PP
-.nf
-int DynDebug(obj, state)
- DynObject obj;
- int state;
-.fi
-.PP
-.IR Modifies :
-obj
-.PP
-.IR Effects :
-Sets the debugging state of
-.I obj
-to
-.I state
-and prints a message on stderr saying what state debugging was set to.
-Any non-zero value for
-.I state
-turns debugging ``on''. When debugging is on, all Dyn functions will
-produce (hopefully useful) output to stderr describing what is going on.
-.PP
-.IR Returns :
-.B DynDebug
-returns DYN_OK.
-.SH AUTHOR
-Barr3y Jaspan, Student Information Processing Board (SIPB) and
-MIT-Project Athena, bjaspan@athena.mit.edu
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the private header file.
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-
-/*
- * dynP.h -- private header file included by source files for libdyn.a.
- */
-
-#ifndef _DynP_h
-#define _DynP_h
-
-#include "dyn.h"
-#ifdef USE_DBMALLOC
-#include <sys/stdtypes.h>
-#include <malloc.h>
-#endif
-
-/*
- * Rep invariant:
- * 1) el_size is the number of bytes per element in the object
- * 2) num_el is the number of elements currently in the object. It is
- * one higher than the highest index at which an element lives.
- * 3) size is the number of elements the object can hold without
- * resizing. num_el <= index.
- * 4) inc is a multiple of the number of elements the object grows by
- * each time it is reallocated.
- */
-
-typedef struct _DynObject DynObjectRecP, *DynObjectP;
-
-/* Internal functions */
-int _DynRealloc (DynObjectP obj, int req),
- _DynResize (DynObjectP obj, int req);
-
-#undef P
-
-#endif /* _DynP_h */
-/* DON'T ADD STUFF AFTER THIS #endif */
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynAppend().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-
-#include "dynP.h"
-
-/*
- * Made obsolete by DynInsert, now just a convenience function.
- */
-int DynAppend(obj, els, num)
- DynObjectP obj;
- DynPtr els;
- int num;
-{
- return DynInsert(obj, DynSize(obj), els, num);
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the functions DynCreate() and
- * DynDestroy().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "dynP.h"
-
-#ifndef DEFAULT_INC
-#define DEFAULT_INC 100
-#endif
-
-static int default_increment = DEFAULT_INC;
-
-DynObjectP DynCreate(el_size, inc)
- int el_size, inc;
-{
- DynObjectP obj;
-
- obj = (DynObjectP) malloc(sizeof(DynObjectRecP));
- if (obj == NULL)
- return NULL;
-
- obj->array = (DynPtr) malloc(1);
- if (obj->array == NULL) {
- free(obj);
- return NULL;
- }
- obj->array[0] = '\0';
-
- obj->el_size = el_size;
- obj->num_el = obj->size = 0;
- obj->debug = obj->paranoid = 0;
- obj->inc = (inc) ? inc : default_increment;
- obj->initzero = 0;
-
- return obj;
-}
-
-DynObjectP DynCopy(obj)
- DynObjectP obj;
-{
- DynObjectP obj1;
-
- obj1 = (DynObjectP) malloc(sizeof(DynObjectRecP));
- if (obj1 == NULL)
- return NULL;
-
- obj1->el_size = obj->el_size;
- obj1->num_el = obj->num_el;
- obj1->size = obj->size;
- obj1->inc = obj->inc;
- obj1->debug = obj->debug;
- obj1->paranoid = obj->paranoid;
- obj1->initzero = obj->initzero;
- obj1->array = (char *) malloc((size_t) (obj1->el_size * obj1->size));
- if (obj1->array == NULL) {
- free(obj1);
- return NULL;
- }
- memcpy(obj1->array, obj->array,
- (size_t) (obj1->el_size * obj1->size));
-
- return obj1;
-}
-
-int DynDestroy(obj)
- /*@only@*/DynObjectP obj;
-{
- if (obj->paranoid) {
- if (obj->debug)
- fprintf(stderr, "dyn: destroy: zeroing %d bytes from %p.\n",
- obj->el_size * obj->size, obj->array);
- memset(obj->array, 0, (size_t) (obj->el_size * obj->size));
- }
- free(obj->array);
- free(obj);
- return DYN_OK;
-}
-
-int DynRelease(obj)
- DynObjectP obj;
-{
- if (obj->debug)
- fprintf(stderr, "dyn: release: freeing object structure.\n");
- free(obj);
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynDebug().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-
-#include "dynP.h"
-
-int DynDebug(obj, state)
- DynObjectP obj;
- int state;
-{
- obj->debug = state;
-
- fprintf(stderr, "dyn: debug: Debug state set to %d.\n", state);
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynDelete().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "dynP.h"
-
-/*
- * Checkers! Get away from that "hard disk erase" button!
- * (Stupid dog. He almost did it to me again ...)
- */
-int DynDelete(obj, idx)
- DynObjectP obj;
- int idx;
-{
- if (idx < 0) {
- if (obj->debug)
- fprintf(stderr, "dyn: delete: bad index %d\n", idx);
- return DYN_BADINDEX;
- }
-
- if (idx >= obj->num_el) {
- if (obj->debug)
- fprintf(stderr, "dyn: delete: Highest index is %d.\n",
- obj->num_el);
- return DYN_BADINDEX;
- }
-
- if (idx == obj->num_el-1) {
- if (obj->paranoid) {
- if (obj->debug)
- fprintf(stderr, "dyn: delete: last element, zeroing.\n");
- memset(obj->array + idx*obj->el_size, 0, (size_t) obj->el_size);
- }
- else {
- if (obj->debug)
- fprintf(stderr, "dyn: delete: last element, punting.\n");
- }
- }
- else {
- if (obj->debug)
- fprintf(stderr,
- "dyn: delete: copying %d bytes from %p + %d to + %d.\n",
- obj->el_size*(obj->num_el - idx), obj->array,
- (idx+1)*obj->el_size, idx*obj->el_size);
-
-#ifdef HAVE_MEMMOVE
- memmove(obj->array + idx*obj->el_size,
- obj->array + (idx+1)*obj->el_size,
- (size_t) obj->el_size*(obj->num_el - idx));
-#else
- bcopy(obj->array + (idx+1)*obj->el_size,
- obj->array + idx*obj->el_size,
- obj->el_size*(obj->num_el - idx));
-#endif
- if (obj->paranoid) {
- if (obj->debug)
- fprintf(stderr,
- "dyn: delete: zeroing %d bytes from %p + %d\n",
- obj->el_size, obj->array,
- obj->el_size*(obj->num_el - 1));
- memset(obj->array + obj->el_size*(obj->num_el - 1), 0,
- (size_t) obj->el_size);
- }
- }
-
- --obj->num_el;
-
- if (obj->debug)
- fprintf(stderr, "dyn: delete: done.\n");
-
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function xxx.
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynInitZero().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-
-#include "dynP.h"
-
-int DynInitzero(obj, state)
- DynObjectP obj;
- int state;
-{
- obj->initzero = state;
-
- if (obj->debug)
- fprintf(stderr, "dyn: initzero: initzero set to %d.\n", state);
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynInsert().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "dynP.h"
-
-int DynInsert(obj, idx, els_in, num)
- DynObjectP obj;
- void *els_in;
- int idx, num;
-{
- DynPtr els = (DynPtr) els_in;
- int ret;
-
- if (idx < 0 || idx > obj->num_el) {
- if (obj->debug)
- fprintf(stderr, "dyn: insert: index %d is not in [0,%d]\n",
- idx, obj->num_el);
- return DYN_BADINDEX;
- }
-
- if (num < 1) {
- if (obj->debug)
- fprintf(stderr, "dyn: insert: cannot insert %d elements\n",
- num);
- return DYN_BADVALUE;
- }
-
- if (obj->debug)
- fprintf(stderr,"dyn: insert: Moving %d bytes from %p + %d to + %d\n",
- (obj->num_el-idx)*obj->el_size, obj->array,
- obj->el_size*idx, obj->el_size*(idx+num));
-
- if ((ret = _DynResize(obj, obj->num_el + num)) != DYN_OK)
- return ret;
-#ifdef HAVE_MEMMOVE
- memmove(obj->array + obj->el_size*(idx + num),
- obj->array + obj->el_size*idx,
- (size_t) ((obj->num_el-idx)*obj->el_size));
-#else
- bcopy(obj->array + obj->el_size*idx,
- obj->array + obj->el_size*(idx + num),
- (obj->num_el-idx)*obj->el_size);
-#endif
-
- if (obj->debug)
- fprintf(stderr, "dyn: insert: Copying %d bytes from %p to %p + %d\n",
- obj->el_size*num, els, obj->array, obj->el_size*idx);
-
-#ifdef HAVE_MEMMOVE
- memmove(obj->array + obj->el_size*idx, els, (size_t) (obj->el_size*num));
-#else
- bcopy(els, obj->array + obj->el_size*idx, obj->el_size*num);
-#endif
- obj->num_el += num;
-
- if (obj->debug)
- fprintf(stderr, "dyn: insert: done.\n");
-
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynDebug().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-
-#include "dynP.h"
-
-int DynParanoid(obj, state)
- DynObjectP obj;
- int state;
-{
- obj->paranoid = state;
-
- if (obj->debug)
- fprintf(stderr, "dyn: paranoid: Paranoia set to %d.\n", state);
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the functions DynGet() and DynAdd().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "dynP.h"
-
-DynPtr DynArray(obj)
- DynObjectP obj;
-{
- if (obj->debug)
- fprintf(stderr, "dyn: array: returning array pointer %p.\n",
- obj->array);
-
- return obj->array;
-}
-
-DynPtr DynGet(obj, num)
- DynObjectP obj;
- int num;
-{
- if (num < 0) {
- if (obj->debug)
- fprintf(stderr, "dyn: get: bad index %d\n", num);
- return NULL;
- }
-
- if (num >= obj->num_el) {
- if (obj->debug)
- fprintf(stderr, "dyn: get: highest element is %d.\n",
- obj->num_el);
- return NULL;
- }
-
- if (obj->debug)
- fprintf(stderr, "dyn: get: Returning address %p + %d.\n",
- obj->array, obj->el_size*num);
-
- return (DynPtr) obj->array + obj->el_size*num;
-}
-
-int DynAdd(obj, el)
- DynObjectP obj;
- void *el;
-{
- int ret;
-
- ret = DynPut(obj, el, obj->num_el);
- if (ret != DYN_OK)
- return ret;
-
- ++obj->num_el;
- return ret;
-}
-
-/*
- * WARNING! There is a reason this function is not documented in the
- * man page. If DynPut used to mutate already existing elements,
- * everything will go fine. If it is used to add new elements
- * directly, however, the state within the object (such as
- * obj->num_el) will not be updated properly and many other functions
- * in the library will lose. Have a nice day.
- */
-int DynPut(obj, el_in, idx)
- DynObjectP obj;
- void *el_in;
- int idx;
-{
- DynPtr el = (DynPtr) el_in;
- int ret;
-
- if (obj->debug)
- fprintf(stderr, "dyn: put: Writing %d bytes from %p to %p + %d\n",
- obj->el_size, el, obj->array, idx*obj->el_size);
-
- if ((ret = _DynResize(obj, idx)) != DYN_OK)
- return ret;
-
-#ifdef HAVE_MEMMOVE
- memmove(obj->array + idx*obj->el_size, el, (size_t) obj->el_size);
-#else
- bcopy(el, obj->array + idx*obj->el_size, obj->el_size);
-#endif
-
- if (obj->debug)
- fprintf(stderr, "dyn: put: done.\n");
-
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the internal function _DynRealloc().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "dynP.h"
-
-/*
- * Resize the array so that element req exists.
- */
-int _DynResize(obj, req)
- DynObjectP obj;
- int req;
-{
- int size;
-
- if (obj->size > req)
- return DYN_OK;
- else if (obj->inc > 0)
- return _DynRealloc(obj, (req - obj->size) / obj->inc + 1);
- else {
- if (obj->size == 0)
- size = -obj->inc;
- else
- size = obj->size;
-
- /*@-shiftsigned@*/
- while (size <= req)
- size <<= 1;
- /*@=shiftsigned@*/
-
- return _DynRealloc(obj, size);
- }
-}
-
-/*
- * Resize the array by num_incs units. If obj->inc is positive, this
- * means make it obj->inc*num_incs elements larger. If obj->inc is
- * negative, this means make the array num_incs elements long.
- *
- * Ideally, this function should not be called from outside the
- * library. However, nothing will break if it is.
- */
-int _DynRealloc(obj, num_incs)
- DynObjectP obj;
- int num_incs;
-{
- DynPtr temp;
- int new_size_in_bytes;
-
- if (obj->inc > 0)
- new_size_in_bytes = obj->el_size*(obj->size + obj->inc*num_incs);
- else
- new_size_in_bytes = obj->el_size*num_incs;
-
- if (obj->debug)
- fprintf(stderr,
- "dyn: alloc: Increasing object by %d bytes (%d incs).\n",
- new_size_in_bytes - obj->el_size*obj->size,
- num_incs);
-
- temp = (DynPtr) realloc(obj->array, (size_t) new_size_in_bytes);
- if (temp == NULL) {
- if (obj->debug)
- fprintf(stderr, "dyn: alloc: Out of memory.\n");
- return DYN_NOMEM;
- }
- else {
- obj->array = temp;
- if (obj->inc > 0)
- obj->size += obj->inc*num_incs;
- else
- obj->size = num_incs;
- }
-
- if (obj->debug)
- fprintf(stderr, "dyn: alloc: done.\n");
-
- return DYN_OK;
-}
+++ /dev/null
-/*
- * This file is part of libdyn.a, the C Dynamic Object library. It
- * contains the source code for the function DynSize().
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-
-#include "dynP.h"
-
-int DynSize(obj)
- DynObjectP obj;
-{
- if (obj->debug)
- fprintf(stderr, "dyn: size: returning size %d.\n", obj->num_el);
-
- return obj->num_el;
-}
-
-int DynCapacity(obj)
- DynObjectP obj;
-{
- if (obj->debug)
- fprintf(stderr, "dyn: capacity: returning cap of %d.\n", obj->size);
-
- return obj->size;
-}
+++ /dev/null
-/*
- * This file is a (rather silly) demonstration of the use of the
- * C Dynamic Object library. It is a also reasonably thorough test
- * of the library (except that it only tests it with one data size).
- *
- * There are no restrictions on this code; however, if you make any
- * changes, I request that you document them so that I do not get
- * credit or blame for your modifications.
- *
- * Written by Barr3y Jaspan, Student Information Processing Board (SIPB)
- * and MIT-Project Athena, 1989.
- */
-
-#include <stdio.h>
-#include <string.h>
-#ifdef USE_DBMALLOC
-#include <sys/stdtypes.h>
-#include <malloc.h>
-#endif
-#include <stdlib.h>
-
-#include "dyn.h"
-
-static char random_string[] = "This is a random string.";
-static char insert1[] = "This will be put at the beginning.";
-static char insert2[] = "(parenthetical remark!) ";
-static char insert3[] = " This follows the random string.";
-
-int
-main(argc, argv)
-/*@unused@*/int argc;
-/*@unused@*/char **argv;
-{
- /*@-exitarg@*/
- DynObject obj;
- int i, s;
- char d, *data;
-
-#ifdef _DEBUG_MALLOC_INC
- union dbmalloptarg arg;
- unsigned long hist1, hist2, o_size, c_size;
-#endif
-
-#ifdef _DEBUG_MALLOC_INC
- arg.i = 0;
- dbmallopt(MALLOC_ZERO, &arg);
- dbmallopt(MALLOC_REUSE, &arg);
-
- o_size = malloc_inuse(&hist1);
-#endif
-
- /*@+matchanyintegral@*/
- obj = DynCreate(sizeof(char), -8);
- if (! obj) {
- fprintf(stderr, "test: create failed.\n");
- exit(1);
- }
-
- if(DynDebug(obj, 1) != DYN_OK) {
- fprintf(stderr, "test: setting paranoid failed.\n");
- exit(1);
- }
- if(DynParanoid(obj, 1) != DYN_OK) {
- fprintf(stderr, "test: setting paranoid failed.\n");
- exit(1);
- }
-
-
- if ((DynGet(obj, -5) != NULL) ||
- (DynGet(obj, 0) != NULL) || (DynGet(obj, 1000) != NULL)) {
- fprintf(stderr, "test: Get did not fail when it should have.\n");
- exit(1);
- }
-
- if (DynDelete(obj, -1) != DYN_BADINDEX ||
- DynDelete(obj, 0) != DYN_BADINDEX ||
- DynDelete(obj, 100) != DYN_BADINDEX) {
- fprintf(stderr, "test: Delete did not fail when it should have.\n");
- exit(1);
- }
-
- printf("Size of empty object: %d\n", DynSize(obj));
-
- for (i=0; i<14; i++) {
- d = (char) i;
- if (DynAdd(obj, &d) != DYN_OK) {
- fprintf(stderr, "test: Adding %d failed.\n", i);
- exit(1);
- }
- }
-
- if (DynAppend(obj, random_string, strlen(random_string)+1) != DYN_OK) {
- fprintf(stderr, "test: appending array failed.\n");
- exit(1);
- }
-
- if (DynDelete(obj, DynHigh(obj) / 2) != DYN_OK) {
- fprintf(stderr, "test: deleting element failed.\n");
- exit(1);
- }
-
- if (DynDelete(obj, DynHigh(obj) * 2) == DYN_OK) {
- fprintf(stderr, "test: delete should have failed here.\n");
- exit(1);
- }
-
- d = '\200';
- if (DynAdd(obj, &d) != DYN_OK) {
- fprintf(stderr, "test: Adding %d failed.\n", i);
- exit(1);
- }
-
- data = (char *) DynGet(obj, 0);
- if(data == NULL) {
- fprintf(stderr, "test: getting object 0 failed.\n");
- exit(1);
- }
- s = DynSize(obj);
- for (i=0; i < s; i++)
- printf("Element %d is %d.\n", i, (int) data[i]);
-
- data = (char *) DynGet(obj, 13);
- if(data == NULL) {
- fprintf(stderr, "test: getting element 13 failed.\n");
- exit(1);
- }
- printf("Element 13 is %d.\n", (int) *data);
-
- data = (char *) DynGet(obj, DynSize(obj));
- if (data) {
- fprintf(stderr, "DynGet did not return NULL when it should have.\n");
- exit(1);
- }
-
- data = DynGet(obj, 14);
- if(data == NULL) {
- fprintf(stderr, "test: getting element 13 failed.\n");
- exit(1);
- }
- printf("This should be the random string: \"%s\"\n", data);
-
- if (DynInsert(obj, -1, "foo", 4) != DYN_BADINDEX ||
- DynInsert(obj, DynSize(obj) + 1, "foo", 4) != DYN_BADINDEX ||
- DynInsert(obj, 0, "foo", -1) != DYN_BADVALUE) {
- fprintf(stderr, "DynInsert did not fail when it should have.\n");
- exit(1);
- }
-
- if (DynInsert(obj, DynSize(obj) - 2, insert3, strlen(insert3) +
- 1) != DYN_OK) {
- fprintf(stderr, "DynInsert to end failed.\n");
- exit(1);
- }
-
- if (DynInsert(obj, 19, insert2, strlen(insert2)) != DYN_OK) {
- fprintf(stderr, "DynInsert to middle failed.\n");
- exit(1);
- }
-
- if (DynInsert(obj, 0, insert1, strlen(insert1)+1) != DYN_OK) {
- fprintf(stderr, "DynInsert to start failed.\n");
- exit(1);
- }
-
- data = DynGet(obj, 14 + strlen(insert1) + 1);
- if (data == NULL) {
- fprintf(stderr, "DynGet of 14+strelen(insert1) failed.\n");
- exit(1);
-
- }
- printf("A new random string: \"%s\"\n", data);
-
- data = DynGet(obj, 0);
- if (data == NULL) {
- fprintf(stderr, "DynGet of 0 failed.\n");
- exit(1);
-
- }
- printf("This was put at the beginning: \"%s\"\n", data);
-
- if(DynDestroy(obj) != DYN_OK) {
- fprintf(stderr, "test: destroy failed.\n");
- exit(1);
- }
-
-#ifdef _DEBUG_MALLOC_INC
- c_size = malloc_inuse(&hist2);
- if (o_size != c_size) {
- printf("\n\nIgnore a single unfreed malloc segment "
- "(stdout buffer).\n\n");
- malloc_list(2, hist1, hist2);
- }
-#endif
-
- printf("All tests pass\n");
-
- return 0;
-}