Resource leak fixes (or hiding them from Coverity static analysis tool by using String instead of char *)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13886 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5a1e82a2f4
commit
46d2486115
12 changed files with 62 additions and 63 deletions
|
|
@ -48,7 +48,7 @@ static File *f_cxx_wrapper = 0;
|
|||
static String *module_name = 0;
|
||||
static String *swig_package = 0;
|
||||
|
||||
const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static bool CWrap = true; // generate wrapper file for C code by default. most correct.
|
||||
static bool Generate_Wrapper = false;
|
||||
|
|
@ -1605,14 +1605,15 @@ void ALLEGROCL::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-cwrap")) {
|
||||
CWrap = true;
|
||||
|
|
|
|||
|
|
@ -792,8 +792,10 @@ public:
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
// Emit warnings for the few cases that can't be overloaded in C# and give up on generating wrapper
|
||||
Swig_overload_check(n);
|
||||
if (Getattr(n, "overload:ignore"))
|
||||
if (Getattr(n, "overload:ignore")) {
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Printv(imclass_class_code, "\n [DllImport(\"", dllimport, "\", EntryPoint=\"", wname, "\")]\n", NIL);
|
||||
|
|
|
|||
|
|
@ -1579,8 +1579,10 @@ public:
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
// Emit warnings for the few cases that can't be overloaded in D and give up on generating wrapper
|
||||
Swig_overload_check(n);
|
||||
if (Getattr(n, "overload:ignore"))
|
||||
if (Getattr(n, "overload:ignore")) {
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Collect the parameter list for the intermediary D module declaration of
|
||||
|
|
|
|||
|
|
@ -3640,6 +3640,7 @@ private:
|
|||
Delete(upcall_name);
|
||||
Delete(callback_wname);
|
||||
Delete(go_name);
|
||||
DelWrapper(w);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ static File *f_wrappers = 0;
|
|||
static File *f_init = 0;
|
||||
|
||||
|
||||
static char *prefix = (char *) "gswig_";
|
||||
static String *prefix = NewString("gswig_");
|
||||
static char *module = 0;
|
||||
static char *package = 0;
|
||||
static String *package = 0;
|
||||
static enum {
|
||||
GUILE_LSTYLE_SIMPLE, // call `SWIG_init()'
|
||||
GUILE_LSTYLE_PASSIVE, // passive linking (no module code)
|
||||
|
|
@ -127,7 +127,7 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
int i, orig_len;
|
||||
int i;
|
||||
|
||||
SWIG_library_directory("guile");
|
||||
SWIG_typemap_lang("guile");
|
||||
|
|
@ -140,8 +140,7 @@ public:
|
|||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -150,8 +149,7 @@ public:
|
|||
}
|
||||
} else if (strcmp(argv[i], "-package") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
package = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(package, argv[i + 1]);
|
||||
package = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -278,12 +276,12 @@ public:
|
|||
// should use Swig_warning() ?
|
||||
Printf(stderr, "guile: Warning: -exportprimitive only makes sense with passive linkage without a scmstub.\n");
|
||||
}
|
||||
// Make sure `prefix' ends in an underscore
|
||||
|
||||
orig_len = strlen(prefix);
|
||||
if (prefix[orig_len - 1] != '_') {
|
||||
prefix[1 + orig_len] = 0;
|
||||
prefix[orig_len] = '_';
|
||||
// Make sure `prefix' ends in an underscore
|
||||
if (prefix) {
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix)] != '_')
|
||||
Printf(prefix, "_");
|
||||
}
|
||||
|
||||
/* Add a symbol for this module */
|
||||
|
|
|
|||
|
|
@ -876,8 +876,10 @@ public:
|
|||
if (Getattr(n, "sym:overloaded")) {
|
||||
// Emit warnings for the few cases that can't be overloaded in Java and give up on generating wrapper
|
||||
Swig_overload_check(n);
|
||||
if (Getattr(n, "overload:ignore"))
|
||||
if (Getattr(n, "overload:ignore")) {
|
||||
DelWrapper(f);
|
||||
return SWIG_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Printf(imclass_class_code, " public final static native %s %s(", im_return_type, overloaded_name);
|
||||
|
|
|
|||
|
|
@ -33,12 +33,10 @@ static String *convert_proto_tab = 0;
|
|||
static String *struct_name = 0;
|
||||
static String *mangled_struct_name = 0;
|
||||
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static bool declaremodule = false;
|
||||
static bool noinit = false;
|
||||
//DLOPEN PATCH
|
||||
static char *load_libraries = NULL;
|
||||
//DLOPEN PATCH
|
||||
static String *load_libraries = NULL;
|
||||
static String *module = 0;
|
||||
static char *mzscheme_path = (char *) "mzscheme";
|
||||
static String *init_func_def = 0;
|
||||
|
|
@ -75,8 +73,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -90,26 +87,27 @@ public:
|
|||
noinit = true;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
else if (strcmp(argv[i], "-dynamic-load") == 0) {
|
||||
load_libraries = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(load_libraries, argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
Delete(load_libraries);
|
||||
load_libraries = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix)] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
@ -177,11 +175,9 @@ public:
|
|||
Printf(f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f_init, "mz_set_dlopen_libraries(\"%s\");\n", load_libraries);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf(f_init, "}\n");
|
||||
|
|
@ -244,14 +240,12 @@ public:
|
|||
int numreq;
|
||||
String *overname = 0;
|
||||
|
||||
// PATCH DLOPEN
|
||||
if (load_libraries) {
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *name = NewString("caller");
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
// Make a wrapper name for this
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
|
|
@ -291,7 +285,6 @@ public:
|
|||
numargs = emit_num_arguments(l);
|
||||
numreq = emit_num_required(l);
|
||||
|
||||
// DLOPEN PATCH
|
||||
/* Add the holder for the pointer to the function to be opened */
|
||||
if (load_libraries) {
|
||||
Wrapper_add_local(f, "_function_loaded", "static int _function_loaded=(1==0)");
|
||||
|
|
@ -302,19 +295,16 @@ public:
|
|||
Wrapper_add_local(f, "caller", SwigType_lstr(d, func)); /*"(*caller)()")); */
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// adds local variables
|
||||
Wrapper_add_local(f, "lenv", "int lenv = 1");
|
||||
Wrapper_add_local(f, "values", "Scheme_Object *values[MAXVALUES]");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f->code, "if (!_function_loaded) { _the_function=mz_load_function(\"%s\");_function_loaded=(1==1); }\n", iname);
|
||||
Printf(f->code, "if (!_the_function) { scheme_signal_error(\"Cannot load C function '%s'\"); }\n", iname);
|
||||
Printf(f->code, "caller=_the_function;\n");
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// Now write code to extract the parameters (this is super ugly)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ static int in_constructor = 0, in_destructor = 0, in_copyconst = 0;
|
|||
static int const_enum = 0;
|
||||
static int static_member_function = 0;
|
||||
static int generate_sizeof = 0;
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static char *ocaml_path = (char *) "ocaml";
|
||||
static bool old_variable_names = false;
|
||||
static String *classname = 0;
|
||||
|
|
@ -107,8 +107,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -130,15 +129,14 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix)] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
|
|||
|
|
@ -524,7 +524,6 @@ public:
|
|||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
String *tm;
|
||||
int j;
|
||||
|
|
@ -551,6 +550,7 @@ public:
|
|||
if (!overloaded || last_overload)
|
||||
process_autodoc(n);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
Octave_begin_function(n, f->def, iname, overname, !overloaded);
|
||||
|
||||
emit_parameter_variables(l, f);
|
||||
|
|
@ -859,6 +859,8 @@ public:
|
|||
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2330,6 +2330,7 @@ done:
|
|||
Printf(f->code, "}\n");
|
||||
|
||||
Wrapper_print(f, s_wrappers);
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -726,6 +726,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Delete(rtype);
|
||||
Delete(rettype);
|
||||
Delete(funcparams);
|
||||
DelWrapper(f);
|
||||
|
||||
return funName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ static struct {
|
|||
String **entries;
|
||||
} defined_foreign_types;
|
||||
|
||||
static const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static int any_varargs(ParmList *pl) {
|
||||
Parm *p;
|
||||
|
|
@ -221,14 +221,15 @@ void UFFI::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue