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;
|
table[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Walk down the old set of nodes */
|
/* Walk down the old set of nodes and re-place */
|
||||||
|
|
||||||
h->hashsize = newsize;
|
h->hashsize = newsize;
|
||||||
for (i = 0; i < oldsize; i++) {
|
for (i = 0; i < oldsize; i++) {
|
||||||
n = h->hashtable[i];
|
n = h->hashtable[i];
|
||||||
|
|
@ -525,7 +524,3 @@ NewHash() {
|
||||||
h->nitems = 0;
|
h->nitems = 0;
|
||||||
return (DOH *) h;
|
return (DOH *) h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,19 +24,9 @@ typedef struct List {
|
||||||
/* Doubles amount of memory in a list */
|
/* Doubles amount of memory in a list */
|
||||||
static
|
static
|
||||||
void more(List *l) {
|
void more(List *l) {
|
||||||
int i;
|
l->items = (void **) DohRealloc(l->items, l->maxitems*2*sizeof(void *));
|
||||||
void **newitems;
|
assert(l->items);
|
||||||
|
|
||||||
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->maxitems *= 2;
|
l->maxitems *= 2;
|
||||||
DohFree(l->items);
|
|
||||||
l->items = newitems;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -55,11 +45,9 @@ CopyList(DOH *lo) {
|
||||||
nl->maxitems = l->maxitems;
|
nl->maxitems = l->maxitems;
|
||||||
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
nl->items = (void **) DohMalloc(l->maxitems*sizeof(void *));
|
||||||
nl->iter = 0;
|
nl->iter = 0;
|
||||||
for (i = 0; i < l->maxitems; i++) {
|
for (i = 0; i < l->nitems; i++) {
|
||||||
nl->items[i] = l->items[i];
|
nl->items[i] = l->items[i];
|
||||||
if (nl->items[i]) {
|
Incref(nl->items[i]);
|
||||||
Incref(nl->items[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
nl->file = l->file;
|
nl->file = l->file;
|
||||||
if (nl->file) Incref(nl->file);
|
if (nl->file) Incref(nl->file);
|
||||||
|
|
@ -78,12 +66,9 @@ DelList(DOH *lo) {
|
||||||
List *l;
|
List *l;
|
||||||
int i;
|
int i;
|
||||||
l = (List *) lo;
|
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]);
|
Delete(l->items[i]);
|
||||||
}
|
|
||||||
DohFree(l->items);
|
DohFree(l->items);
|
||||||
l->items = 0;
|
|
||||||
DohObjFree(l);
|
DohObjFree(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,7 +85,6 @@ List_clear(DOH *lo) {
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
for (i = 0; i < l->nitems; i++) {
|
for (i = 0; i < l->nitems; i++) {
|
||||||
Delete(l->items[i]);
|
Delete(l->items[i]);
|
||||||
l->items[i] = 0;
|
|
||||||
}
|
}
|
||||||
l->nitems = 0;
|
l->nitems = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -122,7 +106,6 @@ List_insert(DOH *lo, int pos, DOH *item) {
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
|
|
||||||
if (!DohCheck(item)) {
|
if (!DohCheck(item)) {
|
||||||
DohTrace(DOH_CONVERSION,"Unknown object %x being converted to a string in List_insert.\n", item);
|
|
||||||
item = NewString(item);
|
item = NewString(item);
|
||||||
Decref(item);
|
Decref(item);
|
||||||
}
|
}
|
||||||
|
|
@ -149,19 +132,16 @@ List_insert(DOH *lo, int pos, DOH *item) {
|
||||||
static int
|
static int
|
||||||
List_remove(DOH *lo, int pos) {
|
List_remove(DOH *lo, int pos) {
|
||||||
List *l;
|
List *l;
|
||||||
DOH *item;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
if (pos == DOH_END) pos = l->nitems-1;
|
if (pos == DOH_END) pos = l->nitems-1;
|
||||||
if (pos == DOH_BEGIN) pos = 0;
|
if (pos == DOH_BEGIN) pos = 0;
|
||||||
if ((pos < 0) || (pos >= l->nitems)) return -1;
|
assert((pos < 0) || (pos >= l->nitems));
|
||||||
item = l->items[pos];
|
Delete(l->items[pos]);
|
||||||
for (i = pos; i < l->nitems-1; i++) {
|
for (i = pos; i < l->nitems-1; i++) {
|
||||||
l->items[i] = l->items[i+1];
|
l->items[i] = l->items[i+1];
|
||||||
}
|
}
|
||||||
l->nitems--;
|
l->nitems--;
|
||||||
Delete(item);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -188,9 +168,7 @@ List_get(DOH *lo, int n) {
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
if (n == DOH_END) n = l->nitems-1;
|
if (n == DOH_END) n = l->nitems-1;
|
||||||
if (n == DOH_BEGIN) n = 0;
|
if (n == DOH_BEGIN) n = 0;
|
||||||
if ((n < 0) || (n >= l->nitems)) {
|
assert((n < 0) || (n >= l->nitems));
|
||||||
printf("List_get : Invalid list index %d\n", n);
|
|
||||||
}
|
|
||||||
return l->items[n];
|
return l->items[n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -205,12 +183,8 @@ List_set(DOH *lo, int n, DOH *val) {
|
||||||
List *l;
|
List *l;
|
||||||
l = (List *) lo;
|
l = (List *) lo;
|
||||||
if (!val) return -1;
|
if (!val) return -1;
|
||||||
if ((n < 0) || (n >= l->nitems)) {
|
assert((n < 0) || (n >= l->nitems));
|
||||||
printf("List_set : Invalid list index %d\n", n);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!DohCheck(val)) {
|
if (!DohCheck(val)) {
|
||||||
DohTrace(DOH_CONVERSION,"Unknown object %x being converted to a string in List_setitem.\n", val);
|
|
||||||
val = NewString(val);
|
val = NewString(val);
|
||||||
Decref(val);
|
Decref(val);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,9 @@ DohCheck(const DOH *ptr) {
|
||||||
Pool *p = Pools;
|
Pool *p = Pools;
|
||||||
char *cptr = (char *) ptr;
|
char *cptr = (char *) ptr;
|
||||||
while (p) {
|
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;
|
p = p->next;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -149,30 +151,3 @@ DohObjFree(DOH *ptr) {
|
||||||
b->objinfo = 0;
|
b->objinfo = 0;
|
||||||
b->flags = b->flags | DOH_FLAG_DELETED;
|
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;
|
int len;
|
||||||
s = (String *) so;
|
s = (String *) so;
|
||||||
if (!DohCheck(str)) {
|
if (!DohCheck(str)) {
|
||||||
DohTrace(DOH_CONVERSION,"Unknown object %x being inserted as char * in String_insert.\n", str);
|
|
||||||
c = (char *) str;
|
c = (char *) str;
|
||||||
len = strlen(c);
|
len = strlen(c);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,8 @@ typedef struct {
|
||||||
static void
|
static void
|
||||||
Void_delete(DOH *vo) {
|
Void_delete(DOH *vo) {
|
||||||
VoidObj *v = (VoidObj *) vo;
|
VoidObj *v = (VoidObj *) vo;
|
||||||
if (v->del) {
|
if (v->del)
|
||||||
(*v->del)(v->ptr);
|
(*v->del)(v->ptr);
|
||||||
}
|
|
||||||
v->del = 0;
|
v->del = 0;
|
||||||
DohObjFree(v);
|
DohObjFree(v);
|
||||||
}
|
}
|
||||||
|
|
@ -78,17 +77,10 @@ static DohObjInfo DohVoidType = {
|
||||||
0, /* doh_sequence */
|
0, /* doh_sequence */
|
||||||
0, /* doh_file */
|
0, /* doh_file */
|
||||||
0, /* doh_string */
|
0, /* doh_string */
|
||||||
0, /* doh_callable */
|
0, /* doh_reserved1 */
|
||||||
0, /* doh_position */
|
0, /* doh_reserved2 */
|
||||||
0, /* reserved5 */
|
|
||||||
0, /* reserved6 */
|
|
||||||
0, /* user1 */
|
|
||||||
0, /* user2 */
|
|
||||||
0, /* user3 */
|
|
||||||
0, /* user4 */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* NewVoid()
|
* NewVoid()
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -116,26 +116,26 @@ typedef struct DohObjInfo {
|
||||||
/* Compare */
|
/* Compare */
|
||||||
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
int (*doh_cmp)(DOH *obj1, DOH *obj2);
|
||||||
|
|
||||||
DohHashMethods *doh_hash; /* Mapping methods */
|
DohHashMethods *doh_hash; /* Hash methods */
|
||||||
DohListMethods *doh_list; /* List methods */
|
DohListMethods *doh_list; /* List methods */
|
||||||
DohFileMethods *doh_file; /* File methods */
|
DohFileMethods *doh_file; /* File methods */
|
||||||
DohStringMethods *doh_string; /* String methods */
|
DohStringMethods *doh_string; /* String methods */
|
||||||
|
void *reserved1;
|
||||||
void *reserved2;
|
void *reserved2;
|
||||||
void *reserved3;
|
|
||||||
void *reserved4;
|
|
||||||
void *reserved5;
|
|
||||||
void *reserved6;
|
|
||||||
void *user1;
|
|
||||||
void *user2;
|
|
||||||
void *user3;
|
|
||||||
void *user4;
|
|
||||||
} DohObjInfo;
|
} DohObjInfo;
|
||||||
|
|
||||||
/* Memory management */
|
/* Memory management */
|
||||||
|
|
||||||
extern void *DohMalloc(size_t size); /* Allocate memory */
|
#ifndef DohMalloc
|
||||||
extern void *DohRealloc(void *, size_t size); /* Reallocate memory */
|
#define DohMalloc malloc
|
||||||
extern void DohFree(DOH *ptr); /* Free memory */
|
#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 *DohObjMalloc(size_t size); /* Allocate a DOH object */
|
||||||
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
extern void DohObjFree(DOH *ptr); /* Free a DOH object */
|
||||||
extern void DohInit(DOH *obj); /* Initialize an object */
|
extern void DohInit(DOH *obj); /* Initialize an object */
|
||||||
|
|
@ -209,9 +209,6 @@ typedef struct DohObjInfo {
|
||||||
|
|
||||||
/* Miscellaneous */
|
/* Miscellaneous */
|
||||||
|
|
||||||
extern void DohTrace(int level, char *fmt,...);
|
|
||||||
extern void DohDebug(int d);
|
|
||||||
|
|
||||||
extern int DohIsMapping(const DOH *obj);
|
extern int DohIsMapping(const DOH *obj);
|
||||||
extern int DohIsSequence(const DOH *obj);
|
extern int DohIsSequence(const DOH *obj);
|
||||||
extern int DohIsString(const DOH *obj);
|
extern int DohIsString(const DOH *obj);
|
||||||
|
|
|
||||||
|
|
@ -41,4 +41,4 @@ dnl Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
dnl Checks for library functions.
|
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