From 779295669e01343caee5412a30b37b88c02fdc9c Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Wed, 17 Jul 2002 22:41:23 +0000 Subject: [PATCH] drop libdyn as a separate library git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14659 dc483132-0cff-0310-8789-dd5450dbe970 --- src/ChangeLog | 5 + src/config/ChangeLog | 5 + src/config/pre.in | 5 +- src/configure.in | 1 - src/krb5-config.in | 2 +- src/util/ChangeLog | 3 + src/util/Makefile.in | 2 +- src/util/dyn/ChangeLog | 105 ------------- src/util/dyn/Imakefile | 26 ---- src/util/dyn/Makefile.ov | 35 ----- src/util/dyn/README | 32 ---- src/util/dyn/TODO | 3 - src/util/dyn/dyn.3m | 198 ----------------------- src/util/dyn/dyn.h | 58 ------- src/util/dyn/dyn.man | 303 ------------------------------------ src/util/dyn/dynP.h | 47 ------ src/util/dyn/dyn_append.c | 26 ---- src/util/dyn/dyn_create.c | 99 ------------ src/util/dyn/dyn_debug.c | 25 --- src/util/dyn/dyn_delete.c | 83 ---------- src/util/dyn/dyn_header.c | 11 -- src/util/dyn/dyn_initzero.c | 26 ---- src/util/dyn/dyn_insert.c | 72 --------- src/util/dyn/dyn_paranoid.c | 26 ---- src/util/dyn/dyn_put.c | 99 ------------ src/util/dyn/dyn_realloc.c | 90 ----------- src/util/dyn/dyn_size.c | 33 ---- src/util/dyn/test.c | 198 ----------------------- 28 files changed, 17 insertions(+), 1601 deletions(-) delete mode 100644 src/util/dyn/ChangeLog delete mode 100644 src/util/dyn/Imakefile delete mode 100644 src/util/dyn/Makefile.ov delete mode 100644 src/util/dyn/README delete mode 100644 src/util/dyn/TODO delete mode 100644 src/util/dyn/dyn.3m delete mode 100644 src/util/dyn/dyn.h delete mode 100644 src/util/dyn/dyn.man delete mode 100644 src/util/dyn/dynP.h delete mode 100644 src/util/dyn/dyn_append.c delete mode 100644 src/util/dyn/dyn_create.c delete mode 100644 src/util/dyn/dyn_debug.c delete mode 100644 src/util/dyn/dyn_delete.c delete mode 100644 src/util/dyn/dyn_header.c delete mode 100644 src/util/dyn/dyn_initzero.c delete mode 100644 src/util/dyn/dyn_insert.c delete mode 100644 src/util/dyn/dyn_paranoid.c delete mode 100644 src/util/dyn/dyn_put.c delete mode 100644 src/util/dyn/dyn_realloc.c delete mode 100644 src/util/dyn/dyn_size.c delete mode 100644 src/util/dyn/test.c diff --git a/src/ChangeLog b/src/ChangeLog index 143677f66..d48b03b70 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2002-07-17 Ken Raeburn + + * configure.in: Don't make a Makefile in util/dyn. + * krb5-config.in: Don't include "-ldyn". + 2002-07-12 Ken Raeburn * aclocal.m4 (KRB5_BUILD_LIBRARY_STATIC): Disable installation of diff --git a/src/config/ChangeLog b/src/config/ChangeLog index 8cfd8617f..ed5761cbe 100644 --- a/src/config/ChangeLog +++ b/src/config/ChangeLog @@ -1,3 +1,8 @@ +2002-07-17 Ken Raeburn + + * pre.in (DYN_DEPLIB): Removed. + (GSSRPC_DEPLIBS, GSSRPC_LIBS): Drop libdyn references. + 2002-07-13 Tom Yu * pre.in (PTY_DEPLIB): Fix to reflect always being built static. diff --git a/src/config/pre.in b/src/config/pre.in index 64337981f..889af4432 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -215,7 +215,6 @@ DES425_DEPLIB = @DES425_DEPLIB@ # $(TOPLIBD)/libdes425$(DEPLIBEXT) 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. @@ -227,7 +226,7 @@ KRB5_BASE_DEPLIBS = $(KRB5_DEPLIB) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) 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) @@ -281,7 +280,7 @@ KRB4COMPAT_LIBS = $(KRB4_LIB) $(DES425_LIB) $(KRB5_BASE_LIBS) 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) diff --git a/src/configure.in b/src/configure.in index 2efe2d2cd..69a389269 100644 --- a/src/configure.in +++ b/src/configure.in @@ -87,7 +87,6 @@ K5_GEN_FILE(krb5-config) 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) diff --git a/src/krb5-config.in b/src/krb5-config.in index 3738c3ec1..e5fec5870 100644 --- a/src/krb5-config.in +++ b/src/krb5-config.in @@ -189,7 +189,7 @@ if test -n "$do_libs"; then fi if test $library = 'kadm_common'; then - lib_flags="$lib_flags -lgssrpc -ldyn" + lib_flags="$lib_flags -lgssrpc" library=gssapi fi diff --git a/src/util/ChangeLog b/src/util/ChangeLog index 2669b70c5..db8aa4f6b 100644 --- a/src/util/ChangeLog +++ b/src/util/ChangeLog @@ -1,5 +1,8 @@ 2002-07-17 Ken Raeburn + * 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. diff --git a/src/util/Makefile.in b/src/util/Makefile.in index b46c286b2..b9d680fb9 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -1,7 +1,7 @@ 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 diff --git a/src/util/dyn/ChangeLog b/src/util/dyn/ChangeLog deleted file mode 100644 index 1ced11574..000000000 --- a/src/util/dyn/ChangeLog +++ /dev/null @@ -1,105 +0,0 @@ -2001-10-09 Ken Raeburn - - * dyn.h, dynP.h: Make prototypes unconditional. Don't define - P(). - -2001-04-25 Ezra Peisach - - * 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 - - * dyn_create.c (DynCopy): Arguments to memcpy were reversed. Found - while playing with lclint. - -2000-11-09 Ezra Peisach - - * 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 - - * dyn_insert.c, dyn_put.c: Include string.h for memmove prototype. - -2000-06-28 Ezra Peisach - - * dyn_create.c, dyn_delete.c, dyn_insert.c, dyn_put.c: Use %p - format for displaying pointers. - -2000-06-26 Ezra Peisach - - * dyn_realloc.c: Remove unused variable. - -1999-10-26 Wilfredo Sanchez - - * 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 - - * 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 - - * Makefile.in: Remove trailing slash from thisconfigdir. Fix up - BUILDTOP for new conventions. - -Wed Jan 28 17:50:30 1998 Theodore Ts'o - - * 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 - - * dyn_delete.c: Include - -Tue Dec 31 13:02:06 1996 Ezra Peisach - - * configure.in, Makefile.in: Update to new library build procedure. - -Mon Jul 22 21:37:52 1996 Ezra Peisach - - * dyn.h: If __STDC__ is not defined, generate prototypes implying - functions and not variables. - -Mon Jul 22 04:20:48 1996 Marc Horowitz - - * dyn_insert.c (DynInsert): what used to be #ifdef POSIX, should - be #ifdef HAVE_MEMMOVE - -Tue Jul 9 19:30:40 1996 Marc Horowitz - - * 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 - - diff --git a/src/util/dyn/Imakefile b/src/util/dyn/Imakefile deleted file mode 100644 index 471cf5bc8..000000000 --- a/src/util/dyn/Imakefile +++ /dev/null @@ -1,26 +0,0 @@ -# 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)) diff --git a/src/util/dyn/Makefile.ov b/src/util/dyn/Makefile.ov deleted file mode 100644 index 8128312c3..000000000 --- a/src/util/dyn/Makefile.ov +++ /dev/null @@ -1,35 +0,0 @@ -# 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 diff --git a/src/util/dyn/README b/src/util/dyn/README deleted file mode 100644 index 0c08ac5c6..000000000 --- a/src/util/dyn/README +++ /dev/null @@ -1,32 +0,0 @@ -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 diff --git a/src/util/dyn/TODO b/src/util/dyn/TODO deleted file mode 100644 index d5a242b98..000000000 --- a/src/util/dyn/TODO +++ /dev/null @@ -1,3 +0,0 @@ -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 diff --git a/src/util/dyn/dyn.3m b/src/util/dyn/dyn.3m deleted file mode 100644 index 21ae70bb2..000000000 --- a/src/util/dyn/dyn.3m +++ /dev/null @@ -1,198 +0,0 @@ - - - -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 _l_i_b_d_y_n._a, and the necessary declarations to use - them are in <_d_y_n._h>. - - 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; - - _R_e_q_u_i_r_e_s: _s_i_z_e and _i_n_c_r_e_m_e_n_t are greater than zero. - - _E_f_f_e_c_t_s: Creates a new DynObject that will store elements of - size _s_i_z_e and will allocate memory in blocks large enough to - hold exactly _i_n_c_r_e_m_e_n_t elements. For example, if you are - storing 8-byte double precision numbers and _i_n_c_r_e_m_e_n_t 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_n_c_r_e_m_e_n_t is zero, a default value is used (currently 100). - This is the only time the programmer deals with a dynamic - object's memory allocation. - - _R_e_t_u_r_n_s: DynCreate returns the new DynObject, or NULL if - there is insufficient memory. - - int DynDestroy(obj) - DynObject obj; - - _M_o_d_i_f_i_e_s: obj - - _E_f_f_e_c_t_s: Frees all memory associated with _o_b_j. The results - of calling any Dyn function on a destroyed object are unde- - fined (except for DynCreate, which resets the object). - - _R_e_t_u_r_n_s: DynDestroy returns DYN_OK. - - - - - - 1 - - - - - - -DYN(3M) 15 March 1990 - - - - int DynAdd(obj, el) - DynObject obj; - DynPtr el; - - _M_o_d_i_f_i_e_s: obj - - _E_f_f_e_c_t_s: Adds the element pointed to by _e_l to the object - _o_b_j, resizing the object if necessary. The new element - becomes the last element in obj's array. - - _R_e_t_u_r_n_s: 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; - - _M_o_d_i_f_i_e_s: obj - - _E_f_f_e_c_t_s: Inserts the array of _n_u_m elements, pointed to by - _e_l_s, into the object _o_b_j starting at the array location - _i_n_d_e_x, 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". - - _R_e_t_u_r_n_s: DynInsert returns DYN_BADINDEX if _i_n_d_e_x is not - between 0 and DynSize(obj); DYN_BADVALUE if _n_u_m is less than - 1; DYN_NOMEM if there is insufficient memory. - - int DynGet(obj, index) - DynObject obj; - int index; - - _E_f_f_e_c_t_s: Returns the address of the element _i_n_d_e_x in the - array of _o_b_j. 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. - - _R_e_t_u_r_n_s: DynGet returns NULL if _i_n_d_e_x is larger than the - number of elements in the array of less than zero. - - int DynDelete(obj, index) - DynObject obj; - int index; - - _M_o_d_i_f_i_e_s: obj - - - - - -2 - - - - - - -15 March 1990 DYN(3M) - - - - _E_f_f_e_c_t_s: The element _i_n_d_e_x is deleted from the object _o_b_j. - 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. - - _R_e_t_u_r_n_s: DynDelete will return DYN_OK on success or - DYN_BADINDEX if the element _i_n_d_e_x does not exist in the - array or is less than zero. - - int DynSize(obj) - DynObject obj; - - _E_f_f_e_c_t_s: Returns the number of elements in the object _o_b_j. - - int DynHigh(obj) - DynObject obj; - - _E_f_f_e_c_t_s: Returns the index of the highest element in the - object _o_b_j. In this version, DynHigh is macro that expands - to DynSize - 1. - - int DynLow(obj) - DynObject obj; - - _E_f_f_e_c_t_s: Returns the index of the lowest element in the - object _o_b_j. In this version, DynLow is macro that expands - to 0. - - int DynDebug(obj, state) - DynObject obj; - int state; - - _M_o_d_i_f_i_e_s: obj - - _E_f_f_e_c_t_s: Sets the debugging state of _o_b_j to _s_t_a_t_e and prints - a message on stderr saying what state debugging was set to. - Any non-zero value for _s_t_a_t_e turns debugging ``on''. When - debugging is on, all Dyn functions will produce (hopefully - useful) output to stderr describing what is going on. - - _R_e_t_u_r_n_s: DynDebug returns DYN_OK. - -AUTHOR - Barr3y Jaspan, Student Information Processing Board (SIPB) - and MIT-Project Athena, bjaspan@athena.mit.edu - - - - - - - - - - 3 - - - diff --git a/src/util/dyn/dyn.h b/src/util/dyn/dyn.h deleted file mode 100644 index 86cd0b205..000000000 --- a/src/util/dyn/dyn.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 */ diff --git a/src/util/dyn/dyn.man b/src/util/dyn/dyn.man deleted file mode 100644 index 3e27459be..000000000 --- a/src/util/dyn/dyn.man +++ /dev/null @@ -1,303 +0,0 @@ -.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 diff --git a/src/util/dyn/dynP.h b/src/util/dyn/dynP.h deleted file mode 100644 index bd86637bb..000000000 --- a/src/util/dyn/dynP.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 -#include -#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 */ diff --git a/src/util/dyn/dyn_append.c b/src/util/dyn/dyn_append.c deleted file mode 100644 index 81403ece7..000000000 --- a/src/util/dyn/dyn_append.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - -#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); -} diff --git a/src/util/dyn/dyn_create.c b/src/util/dyn/dyn_create.c deleted file mode 100644 index 01d1ad4bd..000000000 --- a/src/util/dyn/dyn_create.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 -#include -#include - -#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; -} diff --git a/src/util/dyn/dyn_debug.c b/src/util/dyn/dyn_debug.c deleted file mode 100644 index 4e3e17923..000000000 --- a/src/util/dyn/dyn_debug.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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 - -#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; -} diff --git a/src/util/dyn/dyn_delete.c b/src/util/dyn/dyn_delete.c deleted file mode 100644 index a857ef57c..000000000 --- a/src/util/dyn/dyn_delete.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 -#include - -#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; -} diff --git a/src/util/dyn/dyn_header.c b/src/util/dyn/dyn_header.c deleted file mode 100644 index ffe2c92fb..000000000 --- a/src/util/dyn/dyn_header.c +++ /dev/null @@ -1,11 +0,0 @@ -/* - * 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. - */ diff --git a/src/util/dyn/dyn_initzero.c b/src/util/dyn/dyn_initzero.c deleted file mode 100644 index 3949f30ec..000000000 --- a/src/util/dyn/dyn_initzero.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - -#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; -} diff --git a/src/util/dyn/dyn_insert.c b/src/util/dyn/dyn_insert.c deleted file mode 100644 index f89006bb3..000000000 --- a/src/util/dyn/dyn_insert.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * 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 -#include - -#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; -} diff --git a/src/util/dyn/dyn_paranoid.c b/src/util/dyn/dyn_paranoid.c deleted file mode 100644 index 7eb750a21..000000000 --- a/src/util/dyn/dyn_paranoid.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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 - -#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; -} diff --git a/src/util/dyn/dyn_put.c b/src/util/dyn/dyn_put.c deleted file mode 100644 index 239cea0b3..000000000 --- a/src/util/dyn/dyn_put.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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 -#include - -#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; -} diff --git a/src/util/dyn/dyn_realloc.c b/src/util/dyn/dyn_realloc.c deleted file mode 100644 index 97b3d998f..000000000 --- a/src/util/dyn/dyn_realloc.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 -#include - -#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; -} diff --git a/src/util/dyn/dyn_size.c b/src/util/dyn/dyn_size.c deleted file mode 100644 index b0f497a24..000000000 --- a/src/util/dyn/dyn_size.c +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 - -#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; -} diff --git a/src/util/dyn/test.c b/src/util/dyn/test.c deleted file mode 100644 index 640865d02..000000000 --- a/src/util/dyn/test.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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 -#include -#ifdef USE_DBMALLOC -#include -#include -#endif -#include - -#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; -} -- 2.26.2