From: Ezra Peisach Date: Thu, 9 Nov 2000 19:35:26 +0000 (+0000) Subject: * Makefile.in (check-unix): Built and execture dyntest X-Git-Tag: krb5-1.3-alpha1~1752 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3bba1bd0d74833ee351c466a264b61374c2f5cd9;p=krb5.git * 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. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12866 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/util/dyn/ChangeLog b/src/util/dyn/ChangeLog index afc80b61a..7257ae0ab 100644 --- a/src/util/dyn/ChangeLog +++ b/src/util/dyn/ChangeLog @@ -1,3 +1,17 @@ +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. diff --git a/src/util/dyn/Makefile.in b/src/util/dyn/Makefile.in index 1215998cb..850d36504 100644 --- a/src/util/dyn/Makefile.in +++ b/src/util/dyn/Makefile.in @@ -55,7 +55,13 @@ includes:: dyn.h fi clean-unix:: - $(RM) $(BUILDTOP)/include/dyn.h + $(RM) $(BUILDTOP)/include/dyn.h test.o dyntest + +check-unix:: dyntest + ./dyntest + +dyntest: test.o $(OBJS) + $(CC) -o dyntest test.o $(OBJS) check-windows:: clean-mac:: diff --git a/src/util/dyn/dyn.h b/src/util/dyn/dyn.h index 401565199..f884588de 100644 --- a/src/util/dyn/dyn.h +++ b/src/util/dyn/dyn.h @@ -56,6 +56,7 @@ int DynParanoid P((DynObject obj, int state)); int DynInitzero P((DynObject obj, int state)); int DynSize P((DynObject obj)); int DynCapacity P((DynObject obj)); +int DynAppend P((DynObject obj, DynPtr els, int num)); #undef P diff --git a/src/util/dyn/dynP.h b/src/util/dyn/dynP.h index 0f20ba7c8..6cc6e5867 100644 --- a/src/util/dyn/dynP.h +++ b/src/util/dyn/dynP.h @@ -37,8 +37,18 @@ typedef struct _DynObject DynObjectRecP, *DynObjectP; +/* Function declarations */ +#ifdef __STDC__ +#define P(args) args +#else +#define P(args) () +#endif /* __STDC__ */ + /* Internal functions */ -int _DynRealloc(), _DynResize(); +int _DynRealloc P((DynObjectP obj, int req)), + _DynResize P((DynObjectP obj, int req)); + +#undef P #endif /* _DynP_h */ /* DON'T ADD STUFF AFTER THIS #endif */ diff --git a/src/util/dyn/dyn_create.c b/src/util/dyn/dyn_create.c index 42c0ff73c..237986d5d 100644 --- a/src/util/dyn/dyn_create.c +++ b/src/util/dyn/dyn_create.c @@ -40,7 +40,8 @@ DynObjectP DynCreate(el_size, inc) obj->el_size = el_size; obj->num_el = obj->size = 0; obj->debug = obj->paranoid = 0; - obj->inc = (!! inc) ? inc : default_increment; + obj->inc = (inc) ? inc : default_increment; + obj->initzero = 0; return obj; } @@ -61,7 +62,7 @@ DynObjectP DynCopy(obj) obj1->debug = obj->debug; obj1->paranoid = obj->paranoid; obj1->initzero = obj->initzero; - obj1->array = (char *) malloc(obj1->el_size * obj1->size); + obj1->array = (char *) malloc((size_t) (obj1->el_size * obj1->size)); if (obj1->array == NULL) { free(obj1); return NULL; @@ -79,7 +80,7 @@ int DynDestroy(obj) if (obj->debug) fprintf(stderr, "dyn: destroy: zeroing %d bytes from %p.\n", obj->el_size * obj->size, obj->array); - memset(obj->array, 0, obj->el_size * obj->size); + memset(obj->array, 0, (size_t) (obj->el_size * obj->size)); } free(obj->array); free(obj); diff --git a/src/util/dyn/dyn_delete.c b/src/util/dyn/dyn_delete.c index d8d93e54c..a857ef57c 100644 --- a/src/util/dyn/dyn_delete.c +++ b/src/util/dyn/dyn_delete.c @@ -40,7 +40,7 @@ int DynDelete(obj, idx) if (obj->paranoid) { if (obj->debug) fprintf(stderr, "dyn: delete: last element, zeroing.\n"); - memset(obj->array + idx*obj->el_size, 0, obj->el_size); + memset(obj->array + idx*obj->el_size, 0, (size_t) obj->el_size); } else { if (obj->debug) @@ -57,7 +57,7 @@ int DynDelete(obj, idx) #ifdef HAVE_MEMMOVE memmove(obj->array + idx*obj->el_size, obj->array + (idx+1)*obj->el_size, - obj->el_size*(obj->num_el - idx)); + (size_t) obj->el_size*(obj->num_el - idx)); #else bcopy(obj->array + (idx+1)*obj->el_size, obj->array + idx*obj->el_size, @@ -70,7 +70,7 @@ int DynDelete(obj, idx) obj->el_size, obj->array, obj->el_size*(obj->num_el - 1)); memset(obj->array + obj->el_size*(obj->num_el - 1), 0, - obj->el_size); + (size_t) obj->el_size); } } diff --git a/src/util/dyn/dyn_insert.c b/src/util/dyn/dyn_insert.c index 799ea5d17..f89006bb3 100644 --- a/src/util/dyn/dyn_insert.c +++ b/src/util/dyn/dyn_insert.c @@ -47,7 +47,7 @@ int DynInsert(obj, idx, els_in, num) #ifdef HAVE_MEMMOVE memmove(obj->array + obj->el_size*(idx + num), obj->array + obj->el_size*idx, - (obj->num_el-idx)*obj->el_size); + (size_t) ((obj->num_el-idx)*obj->el_size)); #else bcopy(obj->array + obj->el_size*idx, obj->array + obj->el_size*(idx + num), @@ -59,7 +59,7 @@ int DynInsert(obj, idx, els_in, num) obj->el_size*num, els, obj->array, obj->el_size*idx); #ifdef HAVE_MEMMOVE - memmove(obj->array + obj->el_size*idx, els, obj->el_size*num); + 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 diff --git a/src/util/dyn/dyn_put.c b/src/util/dyn/dyn_put.c index af44374a6..239cea0b3 100644 --- a/src/util/dyn/dyn_put.c +++ b/src/util/dyn/dyn_put.c @@ -87,7 +87,7 @@ int DynPut(obj, el_in, idx) return ret; #ifdef HAVE_MEMMOVE - memmove(obj->array + idx*obj->el_size, el, obj->el_size); + 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 diff --git a/src/util/dyn/dyn_realloc.c b/src/util/dyn/dyn_realloc.c index 0294d0198..229dde08f 100644 --- a/src/util/dyn/dyn_realloc.c +++ b/src/util/dyn/dyn_realloc.c @@ -67,7 +67,7 @@ int _DynRealloc(obj, num_incs) new_size_in_bytes - obj->el_size*obj->size, num_incs); - temp = (DynPtr) realloc(obj->array, new_size_in_bytes); + 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"); diff --git a/src/util/dyn/test.c b/src/util/dyn/test.c index a7a741450..9ac1d0157 100644 --- a/src/util/dyn/test.c +++ b/src/util/dyn/test.c @@ -12,10 +12,14 @@ */ #include +#include #ifdef USE_DBMALLOC #include #include #endif +#ifdef HAVE_STDLIB_H +#include +#endif #include "dyn.h" @@ -24,6 +28,7 @@ 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) int argc; char **argv;