Cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@456 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
26d340bb95
commit
d14bc4e100
8 changed files with 110 additions and 531 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -172,8 +172,7 @@ static void resize(Hash *h) {
|
|||
table[i] = 0;
|
||||
}
|
||||
|
||||
/* Walk down the old set of nodes */
|
||||
|
||||
/* Walk down the old set of nodes and re-place */
|
||||
h->hashsize = newsize;
|
||||
for (i = 0; i < oldsize; i++) {
|
||||
n = h->hashtable[i];
|
||||
|
|
@ -525,7 +524,3 @@ NewHash() {
|
|||
h->nitems = 0;
|
||||
return (DOH *) h;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -24,19 +24,9 @@ typedef struct List {
|
|||
/* Doubles amount of memory in a list */
|
||||
static
|
||||
void more(List *l) {
|
||||
int i;
|
||||
void **newitems;
|
||||
|
||||
newitems = (void **) DohMalloc(l->maxitems*2*sizeof(void *));
|
||||
for (i = 0; i < l->maxitems; i++) {
|
||||
newitems[i] = l->items[i];
|
||||
}
|
||||
for (i = l->maxitems; i < 2*l->maxitems; i++) {
|
||||
newitems[i] = (void *) 0;
|
||||
}
|
||||
l->items = (void **) DohRealloc(l->items, l->maxitems*2*sizeof(void *));
|
||||
assert(l->items);
|
||||
l->maxitems *= 2;
|
||||
DohFree(l->items);
|
||||
l->items = newitems;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -55,11 +45,9 @@ CopyList(DOH *lo) {
|
|||
nl->maxitems = l->maxitems;
|
||||
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
||||
nl->iter = 0;
|
||||
for (i = 0; i < l->maxitems; i++) {
|
||||
for (i = 0; i < l->nitems; i++) {
|
||||
nl->items[i] = l->items[i];
|
||||
if (nl->items[i]) {
|
||||
Incref(nl->items[i]);
|
||||
}
|
||||
Incref(nl->items[i]);
|
||||
}
|
||||
nl->file = l->file;
|
||||
if (nl->file) Incref(nl->file);
|
||||
|
|
@ -78,12 +66,9 @@ DelList(DOH *lo) {
|
|||
List *l;
|
||||
int i;
|
||||
l = (List *) lo;
|
||||
assert(l->refcount <= 0);
|
||||
for (i = 0; i < l->nitems; i++) {
|
||||
for (i = 0; i < l->nitems; i++)
|
||||
Delete(l->items[i]);
|
||||
}
|
||||
DohFree(l->items);
|
||||
l->items = 0;
|
||||
DohObjFree(l);
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +85,6 @@ List_clear(DOH *lo) {
|
|||
l = (List *) lo;
|
||||
for (i = 0; i < l->nitems; i++) {
|
||||
Delete(l->items[i]);
|
||||
l->items[i] = 0;
|
||||
}
|
||||
l->nitems = 0;
|
||||
}
|
||||
|
|
@ -122,7 +106,6 @@ List_insert(DOH *lo, int pos, DOH *item) {
|
|||
l = (List *) lo;
|
||||
|
||||
if (!DohCheck(item)) {
|
||||
DohTrace(DOH_CONVERSION,"Unknown object %x being converted to a string in List_insert.\n", item);
|
||||
item = NewString(item);
|
||||
Decref(item);
|
||||
}
|
||||
|
|
@ -149,19 +132,16 @@ List_insert(DOH *lo, int pos, DOH *item) {
|
|||
static int
|
||||
List_remove(DOH *lo, int pos) {
|
||||
List *l;
|
||||
DOH *item;
|
||||
int i;
|
||||
|
||||
l = (List *) lo;
|
||||
if (pos == DOH_END) pos = l->nitems-1;
|
||||
if (pos == DOH_BEGIN) pos = 0;
|
||||
if ((pos < 0) || (pos >= l->nitems)) return -1;
|
||||
item = l->items[pos];
|
||||
assert((pos < 0) || (pos >= l->nitems));
|
||||
Delete(l->items[pos]);
|
||||
for (i = pos; i < l->nitems-1; i++) {
|
||||
l->items[i] = l->items[i+1];
|
||||
}
|
||||
l->nitems--;
|
||||
Delete(item);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -188,9 +168,7 @@ List_get(DOH *lo, int n) {
|
|||
l = (List *) lo;
|
||||
if (n == DOH_END) n = l->nitems-1;
|
||||
if (n == DOH_BEGIN) n = 0;
|
||||
if ((n < 0) || (n >= l->nitems)) {
|
||||
printf("List_get : Invalid list index %d\n", n);
|
||||
}
|
||||
assert((n < 0) || (n >= l->nitems));
|
||||
return l->items[n];
|
||||
}
|
||||
|
||||
|
|
@ -205,12 +183,8 @@ List_set(DOH *lo, int n, DOH *val) {
|
|||
List *l;
|
||||
l = (List *) lo;
|
||||
if (!val) return -1;
|
||||
if ((n < 0) || (n >= l->nitems)) {
|
||||
printf("List_set : Invalid list index %d\n", n);
|
||||
return -1;
|
||||
}
|
||||
assert((n < 0) || (n >= l->nitems));
|
||||
if (!DohCheck(val)) {
|
||||
DohTrace(DOH_CONVERSION,"Unknown object %x being converted to a string in List_setitem.\n", val);
|
||||
val = NewString(val);
|
||||
Decref(val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ DohCheck(const DOH *ptr) {
|
|||
Pool *p = Pools;
|
||||
char *cptr = (char *) ptr;
|
||||
while (p) {
|
||||
if ((cptr >= p->ptr) && (cptr < p->ptr+p->current)) return 1;
|
||||
if ((cptr >= p->ptr) && (cptr < p->ptr+p->current)) {
|
||||
return 1;
|
||||
}
|
||||
p = p->next;
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -149,30 +151,3 @@ DohObjFree(DOH *ptr) {
|
|||
b->objinfo = 0;
|
||||
b->flags = b->flags | DOH_FLAG_DELETED;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohMalloc() - Wrapper around malloc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void *
|
||||
DohMalloc(size_t nbytes) {
|
||||
return (void *) malloc(nbytes);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohRealloc() - Wrapper around realloc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void *
|
||||
DohRealloc(void *ptr, size_t newsize) {
|
||||
return (void *) realloc(ptr,newsize);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohFree() - Wrapper around free()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
DohFree(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,7 +420,6 @@ String_insert(DOH *so, int pos, DOH *str)
|
|||
int len;
|
||||
s = (String *) so;
|
||||
if (!DohCheck(str)) {
|
||||
DohTrace(DOH_CONVERSION,"Unknown object %x being inserted as char * in String_insert.\n", str);
|
||||
c = (char *) str;
|
||||
len = strlen(c);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -29,9 +29,8 @@ typedef struct {
|
|||
static void
|
||||
Void_delete(DOH *vo) {
|
||||
VoidObj *v = (VoidObj *) vo;
|
||||
if (v->del) {
|
||||
if (v->del)
|
||||
(*v->del)(v->ptr);
|
||||
}
|
||||
v->del = 0;
|
||||
DohObjFree(v);
|
||||
}
|
||||
|
|
@ -78,17 +77,10 @@ static DohObjInfo DohVoidType = {
|
|||
0, /* doh_sequence */
|
||||
0, /* doh_file */
|
||||
0, /* doh_string */
|
||||
0, /* doh_callable */
|
||||
0, /* doh_position */
|
||||
0, /* reserved5 */
|
||||
0, /* reserved6 */
|
||||
0, /* user1 */
|
||||
0, /* user2 */
|
||||
0, /* user3 */
|
||||
0, /* user4 */
|
||||
0, /* doh_reserved1 */
|
||||
0, /* doh_reserved2 */
|
||||
};
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewVoid()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -116,26 +116,26 @@ typedef struct DohObjInfo {
|
|||
/* Compare */
|
||||
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
||||
|
||||
DohHashMethods *doh_hash; /* Mapping methods */
|
||||
DohListMethods *doh_list; /* List methods */
|
||||
DohHashMethods *doh_hash; /* Hash methods */
|
||||
DohListMethods *doh_list; /* List methods */
|
||||
DohFileMethods *doh_file; /* File methods */
|
||||
DohStringMethods *doh_string; /* String methods */
|
||||
void *reserved1;
|
||||
void *reserved2;
|
||||
void *reserved3;
|
||||
void *reserved4;
|
||||
void *reserved5;
|
||||
void *reserved6;
|
||||
void *user1;
|
||||
void *user2;
|
||||
void *user3;
|
||||
void *user4;
|
||||
} DohObjInfo;
|
||||
|
||||
/* Memory management */
|
||||
|
||||
extern void *DohMalloc(size_t size); /* Allocate memory */
|
||||
extern void *DohRealloc(void *, size_t size); /* Reallocate memory */
|
||||
extern void DohFree(DOH *ptr); /* Free memory */
|
||||
#ifndef DohMalloc
|
||||
#define DohMalloc malloc
|
||||
#endif
|
||||
#ifndef DohRealloc
|
||||
#define DohRealloc realloc
|
||||
#endif
|
||||
#ifndef DohFree
|
||||
#define DohFree free
|
||||
#endif
|
||||
|
||||
extern void *DohObjMalloc(size_t size); /* Allocate a DOH object */
|
||||
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
||||
extern void DohInit(DOH *obj); /* Initialize an object */
|
||||
|
|
@ -209,9 +209,6 @@ typedef struct DohObjInfo {
|
|||
|
||||
/* Miscellaneous */
|
||||
|
||||
extern void DohTrace(int level, char *fmt,...);
|
||||
extern void DohDebug(int d);
|
||||
|
||||
extern int DohIsMapping(const DOH *obj);
|
||||
extern int DohIsSequence(const DOH *obj);
|
||||
extern int DohIsString(const DOH *obj);
|
||||
|
|
|
|||
|
|
@ -41,4 +41,4 @@ dnl Checks for header files.
|
|||
AC_HEADER_STDC
|
||||
dnl Checks for library functions.
|
||||
|
||||
AC_OUTPUT(Makefile Doh/Makefile)
|
||||
AC_OUTPUT(Makefile Doh/Makefile Test/Makefile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue