remove many memory leaks and cleanup

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7898 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-11-29 01:47:10 +00:00
commit f714a2615d
21 changed files with 224 additions and 112 deletions

View file

@ -233,12 +233,19 @@ DohEqual(const DOH *obj1, const DOH *obj2) {
if (DohCheck(b2)) {
b2info = b2->type;
} else {
return strncmp((b1info->doh_data)(b1), (void*) obj2, (b1info->doh_len)(b1)) == 0;
int len = (b1info->doh_len)(b1);
char *cobj = (char *) obj2;
return len == strlen(cobj) ? (memcmp(RawData(b1), cobj, len) == 0) : 0;
}
} else if (DohCheck(b2)) {
b2info = b2->type;
return strncmp((b2info->doh_data)(b2), (void*) obj1, (b2info->doh_len)(b2)) == 0;
int len = (b2info->doh_len)(b2);
char *cobj = (char *) obj1;
return len == strlen(cobj) ? (memcmp(RawData(b2), cobj, len) == 0) : 0;
} else {
return strcmp((char*) obj1, (char*) obj2) == 0;
}
if (!b1info) {
return obj1 == obj2;
} else if ((b1info == b2info)) {

View file

@ -263,10 +263,10 @@ extern int DohString_equal(DOH *s1, DOH *s2);
#define DohStringPutc(ch,so) DohString_putc(so, ch)
#define DohStringGetc(so) DohString_getc(so)
#define DohStringUngetc(ch,so) DohString_ungetc(so, ch)
#define DohStringAppend(so,str) DohString_append(so, str)
#define DohStringLen(so) DohString_len(so)
#define DohStringAppend(so,str) DohString_append(so, (DOH*)str)
#define DohStringLen(so) DohString_len((DOH*)so)
#define DohStringChar(so) DohString_char(so)
#define DohStringEqual(s1,s2) DohString_equal(s1,s2)
#define DohStringEqual(s1,s2) DohString_equal((DOH *)s1, (DOH *)s2)
/* Meta-variables */
extern DOH *DohGetmeta(DOH *, const DOH *);

View file

@ -150,6 +150,7 @@ DohString_equal(DOH *so1, DOH *so2)
} else {
register char *c1 = s1->str;
register char *c2 = s2->str;
#if 0
register int mlen = len >> 2;
register int i = mlen;
for (; i; --i) {
@ -162,6 +163,9 @@ DohString_equal(DOH *so1, DOH *so2)
if (*(c1++) != *(c2++)) return 0;
}
return 1;
#else
return memcmp(c1, c2, len) == 0;
#endif
}
}
@ -208,7 +212,7 @@ DohString_append(DOH *so, DOH *str) {
if (DohCheck(str)) {
String *ss = (String *) ObjData(str);
newstr = String_data(str);
newstr = String_data((DOH*)str);
l = ss->len;
} else {
newstr = (char *) (str);
@ -667,8 +671,6 @@ replace_simple(String *str, char *token, char *rep, int flags, int count, char *
register char *base;
int i;
str->hashkey = -1;
/* Figure out if anything gets replaced */
if (!strlen(token)) return 0;
@ -678,6 +680,8 @@ replace_simple(String *str, char *token, char *rep, int flags, int count, char *
if (!s) return 0; /* No matches. Who cares */
str->hashkey = -1;
if (flags & DOH_REPLACE_NOQUOTE) noquote = 1;
/* If we are not replacing inside quotes, we need to do a little extra work */