From 8439fc6c1905b25c435649fcd00aab9914578265 Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 9 Jun 2008 17:46:33 -0700 Subject: [PATCH] Remove two memory leaks. This patch removes two memory leaks. One in the driver and one in the runtime. --- driver/main.c | 23 ++++++++++++----------- vvp/vpi_callback.cc | 7 ++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/driver/main.c b/driver/main.c index 55fac84b3..6520e6bf3 100644 --- a/driver/main.c +++ b/driver/main.c @@ -266,6 +266,7 @@ static const char*my_tempfile(const char*str, FILE**fout) */ static int t_default(char*cmd, unsigned ncmd) { + int rtn = 0; unsigned rc; #ifdef __MINGW32__ unsigned ncmd_start = ncmd; @@ -328,23 +329,24 @@ static int t_default(char*cmd, unsigned ncmd) remove(compiled_defines_path); } #ifdef __MINGW32__ /* MinGW just returns the exit status, so return it! */ + free(cmd); return rc; #else if (rc != 0) { if (rc == 127) { fprintf(stderr, "Failed to execute: %s\n", cmd); - return 1; - } - - if (WIFEXITED(rc)) - return WEXITSTATUS(rc); - - fprintf(stderr, "Command signaled: %s\n", cmd); - return -1; + rtn = 1; + } else if (WIFEXITED(rc)) { + rtn = WEXITSTATUS(rc); + } else { + fprintf(stderr, "Command signaled: %s\n", cmd); + rtn = -1; + } } - return 0; + free(cmd); + return rtn; #endif } @@ -871,6 +873,7 @@ int main(int argc, char **argv) } fprintf(stderr, "Command signaled: %s\n", cmd); + free(cmd); return -1; } @@ -889,6 +892,4 @@ int main(int argc, char **argv) fclose(iconfig_file); return t_default(cmd, ncmd); - - return 0; } diff --git a/vvp/vpi_callback.cc b/vvp/vpi_callback.cc index 6313c3896..0c03e27d2 100644 --- a/vvp/vpi_callback.cc +++ b/vvp/vpi_callback.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2003 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -16,9 +16,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_callback.cc,v 1.46 2007/04/10 04:32:05 steve Exp $" -#endif /* * Callbacks are objects that carry a function to be called when some @@ -108,6 +105,7 @@ void delete_vpi_callback(struct __vpiCallback* ref) assert(ref); assert(ref->base.vpi_type); assert(ref->base.vpi_type->type_code == vpiCallback); + if (ref->cb_sync != 0) delete ref->cb_sync; delete ref; } @@ -626,4 +624,3 @@ void vvp_fun_signal_real::get_value(struct t_vpi_value*vp) vp->format); } } -