/*
* This file is the collected implementation of libdyn.a, the C
* Dynamic Object library. It contains everything.
*
* 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.
*
* 2002-07-17 Collected full implementation into one source file for
* easy inclusion into the one library still dependent on
* libdyn. Assume memmove. Old ChangeLog appended.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "dynP.h"
/* old dyn_append.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynAppend().
*/
/*
* Made obsolete by DynInsert, now just a convenience function.
*/
int num;
{
}
/* old dyn_create.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the functions DynCreate() and
* DynDestroy().
*/
#ifndef DEFAULT_INC
#endif
{
return NULL;
return NULL;
}
return obj;
}
{
return NULL;
return NULL;
}
return obj1;
}
{
}
return DYN_OK;
}
{
return DYN_OK;
}
/* old dyn_debug.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynDebug().
*/
int state;
{
return DYN_OK;
}
/* old dyn_delete.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynDelete().
*/
/*
* Checkers! Get away from that "hard disk erase" button!
* (Stupid dog. He almost did it to me again ...)
*/
int idx;
{
if (idx < 0) {
return DYN_BADINDEX;
}
return DYN_BADINDEX;
}
}
else {
}
}
else {
"dyn: delete: copying %d bytes from %p + %d to + %d.\n",
"dyn: delete: zeroing %d bytes from %p + %d\n",
}
}
return DYN_OK;
}
/* old dyn_initzero.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynInitZero().
*/
int state;
{
return DYN_OK;
}
/* old dyn_insert.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynInsert().
*/
void *els_in;
{
int ret;
return DYN_BADINDEX;
}
if (num < 1) {
num);
return DYN_BADVALUE;
}
return ret;
return DYN_OK;
}
/* old dyn_paranoid.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynDebug().
*/
int state;
{
return DYN_OK;
}
/* old dyn_put.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the functions DynGet() and DynAdd().
*/
{
}
int num;
{
if (num < 0) {
return NULL;
}
return NULL;
}
}
void *el;
{
int ret;
return ret;
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.
*/
void *el_in;
int idx;
{
int ret;
return ret;
return DYN_OK;
}
/* old dyn_realloc.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the internal function _DynRealloc().
*/
/*
* Resize the array so that element req exists.
*/
int req;
{
int size;
return DYN_OK;
else {
else
/*@-shiftsigned@*/
size <<= 1;
/*@=shiftsigned@*/
}
}
/*
* 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 num_incs;
{
int new_size_in_bytes;
else
"dyn: alloc: Increasing object by %d bytes (%d incs).\n",
num_incs);
return DYN_NOMEM;
}
else {
else
}
return DYN_OK;
}
/* old dyn_size.c */
/*
* This file is part of libdyn.a, the C Dynamic Object library. It
* contains the source code for the function DynSize().
*/
{
}
{
}
/* Old change log, as it relates to source code; build system stuff
discarded.
2001-10-09 Ken Raeburn <raeburn@mit.edu>
P().
2001-04-25 Ezra Peisach <epeisach@mit.edu>
* 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.
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>
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.
Sat Dec 6 22:50:03 1997 Ezra Peisach <epeisach@mit.edu>
* dyn_delete.c: Include <string.h>
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
*/