From: Marcelo M. <mar...@us...> - 2005-11-29 01:47:21
|
Update of /cvsroot/swig/SWIG/Source/Preprocessor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18999/Source/Preprocessor Modified Files: cpp.c Log Message: remove many memory leaks and cleanup Index: cpp.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Preprocessor/cpp.c,v retrieving revision 1.72 retrieving revision 1.73 diff -C2 -d -r1.72 -r1.73 *** cpp.c 28 Nov 2005 17:32:56 -0000 1.72 --- cpp.c 29 Nov 2005 01:47:10 -0000 1.73 *************** *** 91,99 **** } } else { Seek(s,0,SEEK_SET); if (!dependencies) { dependencies = NewList(); } ! Append(dependencies, Copy(Swig_last_file())); } return s; --- 91,102 ---- } } else { + String *lf; Seek(s,0,SEEK_SET); if (!dependencies) { dependencies = NewList(); } ! lf = Copy(Swig_last_file()); ! Append(dependencies, lf); ! Delete(lf); } return s; *************** *** 214,221 **** s = Char(argname); dots = strchr(s, '.'); ! if (!dots) return NULL; if (strcmp(dots, "...") != 0) { Swig_error(Getfile(line), Getline(line), "Illegal macro argument name '%s'\n", str); return NULL; } --- 217,229 ---- s = Char(argname); dots = strchr(s, '.'); ! if (!dots) { ! Delete(argname); ! return NULL; ! } ! if (strcmp(dots, "...") != 0) { Swig_error(Getfile(line), Getline(line), "Illegal macro argument name '%s'\n", str); + Delete(argname); return NULL; } *************** *** 224,228 **** } else { *dots = '\0'; ! varargname = NewStringf(argname); } Delete(argname); --- 232,236 ---- } else { *dots = '\0'; ! varargname = NewString(s); } Delete(argname); *************** *** 230,234 **** } ! Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) { String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; --- 238,242 ---- } ! Hash *Preprocessor_define(const String *str, int swigmacro) { String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; *************** *** 237,241 **** int c, line; int varargs = 0; - String_or_char *str = (String_or_char *) _str; assert(cpp); --- 245,248 ---- *************** *** 308,311 **** --- 315,319 ---- varargname = Macro_vararg_name(argname, str); if (varargname) { + Delete(varargname); Swig_error(Getfile(str),Getline(str),"Variable-length macro argument must be last parameter\n"); } else { *************** *** 317,324 **** StringPutc(c,argname); } else if (!(isspace(c) || (c == '\\'))) { Swig_error(Getfile(str),Getline(str),"Illegal character in macro argument name\n"); goto macro_error; } ! } if (Len(argname)) { /* Check for varargs */ --- 325,333 ---- StringPutc(c,argname); } else if (!(isspace(c) || (c == '\\'))) { + Delete(argname); Swig_error(Getfile(str),Getline(str),"Illegal character in macro argument name\n"); goto macro_error; } ! } if (Len(argname)) { /* Check for varargs */ *************** *** 331,336 **** Append(arglist,argname); } - Delete(argname); } } --- 340,345 ---- Append(arglist,argname); } } + Delete(argname); } *************** *** 410,413 **** --- 419,423 ---- macro = NewHash(); Setattr(macro,k_name, macroname); + if (arglist) { Setattr(macro,k_args,arglist); *************** *** 433,440 **** } Setattr(symbols,macroname,macro); Delete(str); Delete(argstr); - Delete(macroname); return macro; --- 443,450 ---- } Setattr(symbols,macroname,macro); + Delete(macroname); Delete(str); Delete(argstr); return macro; *************** *** 442,445 **** --- 452,456 ---- Delete(str); Delete(argstr); + Delete(arglist); Delete(macroname); return 0; *************** *** 1030,1036 **** } } - #ifndef SWIG_PUT_BUFF Delete(id); - #endif return ns; } --- 1041,1045 ---- *************** *** 1104,1108 **** push_imported() { if (imported_depth == 0) { ! Preprocessor_define("SWIGIMPORTED 1", 0); } ++imported_depth; --- 1113,1118 ---- push_imported() { if (imported_depth == 0) { ! DOH *m = Preprocessor_define("SWIGIMPORTED 1", 0); ! Delete(m); } ++imported_depth; *************** *** 1679,1683 **** if (allow) { Seek(value,0,SEEK_SET); ! Preprocessor_define(value,1); } StringPutc('\n',ns); --- 1689,1694 ---- if (allow) { Seek(value,0,SEEK_SET); ! DOH *m = Preprocessor_define(value,1); ! Delete(m); } StringPutc('\n',ns); |