* 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
+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.
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::
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
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 */
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;
}
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;
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);
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)
#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,
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);
}
}
#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),
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
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
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");
*/
#include <stdio.h>
+#include <string.h>
#ifdef USE_DBMALLOC
#include <sys/stdtypes.h>
#include <malloc.h>
#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
#include "dyn.h"
static char insert2[] = "(parenthetical remark!) ";
static char insert3[] = " This follows the random string.";
+int
main(argc, argv)
int argc;
char **argv;