diff --git a/StringHeap.cc b/StringHeap.cc index 8b8b0cde1..a9ec03839 100644 --- a/StringHeap.cc +++ b/StringHeap.cc @@ -18,6 +18,7 @@ */ # include "StringHeap.h" +# include "ivl_alloc.h" # include # include # include diff --git a/cadpli/cadpli.c b/cadpli/cadpli.c index 6e25c324c..572d73681 100644 --- a/cadpli/cadpli.c +++ b/cadpli/cadpli.c @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +# include "ivl_alloc.h" # include # include # include diff --git a/driver/main.c b/driver/main.c index 42505991f..b3c472c22 100644 --- a/driver/main.c +++ b/driver/main.c @@ -50,6 +50,7 @@ const char HELP[] = #define MAXSIZE 4096 +#include "ivl_alloc.h" #include #include #include @@ -886,7 +887,8 @@ int main(int argc, char **argv) break; case 'P': defparm_size += 1; - defparm_base = (const char**)realloc(defparm_base, defparm_size*sizeof(char*)); + defparm_base = (const char**)realloc(defparm_base, + defparm_size*sizeof(char*)); defparm_base[defparm_size-1] = optarg; break; case 'p': diff --git a/driver/substit.c b/driver/substit.c index ac744deae..e90c9f899 100644 --- a/driver/substit.c +++ b/driver/substit.c @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +# include "ivl_alloc.h" # include # include # include diff --git a/ivl_alloc.h b/ivl_alloc.h new file mode 100644 index 000000000..577e8fd28 --- /dev/null +++ b/ivl_alloc.h @@ -0,0 +1,86 @@ +#ifndef __ivl_alloc_H +#define __ivl_alloc_H +/* + * Copyright (C) 2010 Cary R. (cygcary@yahoo.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifdef __cplusplus +# include +# include +#else +# include +# include +#endif + +/* + * Define a safer version of malloc(). + */ + +#define malloc(__ivl_size) \ +({ \ + /* To be safe we only evaluate the argument once. */ \ + size_t __ivl_lsize = __ivl_size; \ + void *__ivl_rtn = malloc(__ivl_lsize); \ + /* If we run out of memory then exit with a message. */ \ + if ((__ivl_rtn == NULL) && (__ivl_lsize != 0)) { \ + fprintf(stderr, "%s:%d: Error: malloc() ran out of memory.\n", \ + __FILE__, __LINE__); \ + exit(1); \ + } \ + __ivl_rtn; \ +}) + +/* + * Define a safer version of realloc(). + */ + +#define realloc(__ivl_ptr, __ivl_size) \ +({ \ + /* To be safe we only evaluate the arguments once. */ \ + void *__ivl_lptr = __ivl_ptr; \ + size_t __ivl_lsize = __ivl_size; \ + void *__ivl_rtn = realloc(__ivl_lptr, __ivl_lsize); \ + /* If we run out of memory then exit with a message. */ \ + if ((__ivl_rtn == NULL) && (__ivl_lsize != 0)) { \ + fprintf(stderr, "%s:%d: Error: realloc() ran out of memory.\n", \ + __FILE__, __LINE__); \ + free(__ivl_lptr); \ + exit(1); \ + } \ + __ivl_rtn; \ +}) + +/* + * Define a safer version of calloc(). + */ + +#define calloc(__ivl_count, __ivl_size) \ +({ \ + /* To be safe we only evaluate the arguments once. */ \ + size_t __ivl_lcount = __ivl_count; \ + size_t __ivl_lsize = __ivl_size; \ + void *__ivl_rtn = calloc(__ivl_lcount, __ivl_lsize); \ + /* If we run out of memory then exit with a message. */ \ + if ((__ivl_rtn == NULL) && (__ivl_lcount != 0) && (__ivl_lsize != 0)) { \ + fprintf(stderr, "%s:%d: Error: calloc() ran out of memory.\n", \ + __FILE__, __LINE__); \ + exit(1); \ + } \ + __ivl_rtn; \ +}) + +#endif diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 0dc93a8ed..3c1a630c2 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -20,6 +20,7 @@ # include "config.h" +# include "ivl_alloc.h" # include # include # include @@ -977,7 +978,7 @@ static void do_define() } /* Accumulate this text into the define_text string. */ - define_text = realloc(define_text, define_cnt + (cp-yytext) + 1); assert(define_text != 0); + define_text = realloc(define_text, define_cnt + (cp-yytext) + 1); head = &define_text[define_cnt]; strcpy(head, yytext); @@ -1023,7 +1024,7 @@ static void do_define() char* base = define_text; define_cnt += added_cnt; - define_text = realloc(define_text, define_cnt + 1); assert(define_text != 0); + define_text = realloc(define_text, define_cnt + 1); head = &define_text[head - base]; tail = &define_text[tail - base]; @@ -1280,7 +1281,7 @@ static void exp_buf_grow_to_fit(int length) { exp_buf_size += EXP_BUF_CHUNK; exp_buf_free += EXP_BUF_CHUNK; - exp_buf = realloc(exp_buf, exp_buf_size); assert(exp_buf != 0); + exp_buf = realloc(exp_buf, exp_buf_size); } } diff --git a/ivlpp/main.c b/ivlpp/main.c index 7a8b4241d..7e9a260a5 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -37,6 +37,7 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; +# include "ivl_alloc.h" # include # include # include diff --git a/libveriuser/a_vcl.c b/libveriuser/a_vcl.c index 9594480aa..855a8bc2d 100644 --- a/libveriuser/a_vcl.c +++ b/libveriuser/a_vcl.c @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +#include "ivl_alloc.h" #include #include #include diff --git a/libveriuser/veriusertfs.c b/libveriuser/veriusertfs.c index a8e291071..7f16cfe4f 100644 --- a/libveriuser/veriusertfs.c +++ b/libveriuser/veriusertfs.c @@ -23,6 +23,7 @@ * via VPI. This is extremely ugly, so don't look after eating dinner. */ +# include "ivl_alloc.h" # include # include # include @@ -104,7 +105,6 @@ void veriusertfs_register_table(p_tfcell vtable) /* squirrel away veriusertfs in persistent user_data */ data = calloc(1, sizeof(s_pli_data)); - assert(data != NULL); udata_count += 1; udata_store = (p_pli_data*)realloc(udata_store, udata_count*sizeof(p_pli_data*)); @@ -222,7 +222,6 @@ static PLI_INT32 compiletf(char *data) while ((arg_h = vpi_scan(arg_i)) != NULL) { /* replicate user_data for each instance */ dp = calloc(1, sizeof(s_pli_data)); - assert(dp != NULL); memcpy(dp, cb_data.user_data, sizeof(s_pli_data)); dp->paramvc = paramvc++; cb_data.user_data = (char *)dp; diff --git a/libveriuser/workarea.c b/libveriuser/workarea.c index bf722d491..c42125881 100644 --- a/libveriuser/workarea.c +++ b/libveriuser/workarea.c @@ -17,6 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ +# include "ivl_alloc.h" # include # include # include diff --git a/load_module.cc b/load_module.cc index bbd4dc8dd..c5b32efd8 100644 --- a/load_module.cc +++ b/load_module.cc @@ -21,6 +21,7 @@ # include "util.h" # include "parse_api.h" # include "compiler.h" +# include "ivl_alloc.h" # include # include # include diff --git a/main.cc b/main.cc index ff5ee6f48..dc69e57e7 100644 --- a/main.cc +++ b/main.cc @@ -38,6 +38,7 @@ const char NOTICE[] = " 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n" ; +# include "ivl_alloc.h" # include # include # include diff --git a/net_link.cc b/net_link.cc index e53f9da6a..f866bdc9b 100644 --- a/net_link.cc +++ b/net_link.cc @@ -22,6 +22,7 @@ # include # include "netlist.h" +# include "ivl_alloc.h" # include # include # include diff --git a/pform.cc b/pform.cc index 7b5566018..5949f3091 100644 --- a/pform.cc +++ b/pform.cc @@ -28,6 +28,7 @@ # include "PGenerate.h" # include "PSpec.h" # include "discipline.h" +# include "ivl_alloc.h" # include # include # include diff --git a/t-dll-analog.cc b/t-dll-analog.cc index 7d37be0a3..f5861500b 100644 --- a/t-dll-analog.cc +++ b/t-dll-analog.cc @@ -22,6 +22,7 @@ # include +# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" @@ -49,7 +50,6 @@ bool dll_target::process(const NetAnalogTop*net) assert(stmt_cur_ == 0); stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_); - assert(stmt_cur_); rc_flag = net->statement()->emit_proc(this) && rc_flag; assert(stmt_cur_); diff --git a/t-dll-api.cc b/t-dll-api.cc index d33c3f1c2..285ab6e3a 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -21,6 +21,7 @@ # include "StringHeap.h" # include "t-dll.h" # include "discipline.h" +# include "ivl_alloc.h" # include # include # include diff --git a/t-dll-expr.cc b/t-dll-expr.cc index 57fcc146f..542738022 100644 --- a/t-dll-expr.cc +++ b/t-dll-expr.cc @@ -19,6 +19,7 @@ # include "config.h" +# include "ivl_alloc.h" # include # include @@ -118,7 +119,6 @@ void dll_target::mul_expr_by_const_(long val) ivl_expr_t dll_target::expr_from_value_(const verinum&val) { ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr); unsigned idx; char*bits; @@ -180,7 +180,6 @@ void dll_target::expr_binary(const NetEBinary*net) ivl_expr_t rght = expr_; expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); expr_->type_ = IVL_EX_BINARY; expr_->value_= get_expr_type(net); @@ -225,7 +224,6 @@ void dll_target::expr_const(const NetEConst*net) assert(expr_ == 0); expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); expr_->value_= net->expr_type(); FILE_NAME(expr_, net); @@ -312,7 +310,6 @@ void dll_target::expr_event(const NetEEvent*net) assert(expr_ == 0); expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); expr_->type_ = IVL_EX_EVENT; FILE_NAME(expr_, net); @@ -337,7 +334,6 @@ void dll_target::expr_scope(const NetEScope*net) assert(expr_ == 0); expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); expr_->type_ = IVL_EX_SCOPE; expr_->value_= IVL_VT_VOID; @@ -358,7 +354,6 @@ void dll_target::expr_select(const NetESelect*net) ivl_expr_t rght = expr_; expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); FILE_NAME(expr_, net); expr_->type_ = IVL_EX_SELECT; @@ -376,7 +371,6 @@ void dll_target::expr_sfunc(const NetESFunc*net) assert(expr_ == 0); ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr); expr->type_ = IVL_EX_SFUNC; FILE_NAME(expr, net); @@ -407,7 +401,6 @@ void dll_target::expr_ternary(const NetETernary*net) assert(expr_ == 0); ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr); expr->type_ = IVL_EX_TERNARY; FILE_NAME(expr, net); @@ -449,7 +442,6 @@ void dll_target::expr_signal(const NetESignal*net) } expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr_); expr_->type_ = IVL_EX_SIGNAL; expr_->value_= net->expr_type(); @@ -478,7 +470,6 @@ void dll_target::expr_ufunc(const NetEUFunc*net) assert(expr_ == 0); ivl_expr_t expr = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s)); - assert(expr); expr->type_ = IVL_EX_UFUNC; FILE_NAME(expr, net); diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 6b18479f0..32f33e767 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -22,6 +22,7 @@ # include +# include "ivl_alloc.h" # include # include "target.h" # include "ivl_target.h" @@ -59,7 +60,6 @@ bool dll_target::process(const NetProcTop*net) assert(stmt_cur_ == 0); stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_); - assert(stmt_cur_); rc_flag = net->statement()->emit_proc(this) && rc_flag; assert(stmt_cur_); @@ -80,7 +80,6 @@ void dll_target::task_def(const NetScope*net) assert(stmt_cur_ == 0); stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_); - assert(stmt_cur_); def->proc()->emit_proc(this); assert(stmt_cur_); @@ -96,7 +95,6 @@ bool dll_target::func_def(const NetScope*net) assert(stmt_cur_ == 0); stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_); - assert(stmt_cur_); def->proc()->emit_proc(this); assert(stmt_cur_); diff --git a/t-dll.cc b/t-dll.cc index f5d2771e9..1db7a6fc9 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -21,6 +21,7 @@ # include +# include "ivl_alloc.h" # include # include // sprintf() # include "compiler.h" @@ -561,9 +562,12 @@ void dll_target::add_root(ivl_design_s &des__, const NetScope *s) des__.nroots_++; if (des__.roots_) - des__.roots_ = (ivl_scope_t *)realloc(des__.roots_, des__.nroots_ * sizeof(ivl_scope_t)); + des__.roots_ = (ivl_scope_t *)realloc(des__.roots_, + des__.nroots_ * + sizeof(ivl_scope_t)); else - des__.roots_ = (ivl_scope_t *)malloc(des__.nroots_ * sizeof(ivl_scope_t)); + des__.roots_ = (ivl_scope_t *)malloc(des__.nroots_ * + sizeof(ivl_scope_t)); des__.roots_[des__.nroots_ - 1] = root_; } @@ -1256,7 +1260,6 @@ void dll_target::udp(const NetUDP*net) u = new struct ivl_udp_s; u->nrows = net->rows(); u->table = (ivl_udp_s::ccharp_t*)malloc((u->nrows+1)*sizeof(char*)); - assert(u->table); u->table[u->nrows] = 0x0; u->nin = net->nin(); u->sequ = net->is_sequential(); diff --git a/tgt-fpga/d-generic-edif.c b/tgt-fpga/d-generic-edif.c index 433bf55f1..71740d0c1 100644 --- a/tgt-fpga/d-generic-edif.c +++ b/tgt-fpga/d-generic-edif.c @@ -19,6 +19,7 @@ # include "device.h" # include "fpga_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-fpga/edif.c b/tgt-fpga/edif.c index a77451e22..0739f5a61 100644 --- a/tgt-fpga/edif.c +++ b/tgt-fpga/edif.c @@ -18,6 +18,7 @@ */ # include "edif.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-fpga/mangle.c b/tgt-fpga/mangle.c index 03af19de3..0138f82d3 100644 --- a/tgt-fpga/mangle.c +++ b/tgt-fpga/mangle.c @@ -18,6 +18,7 @@ */ # include "fpga_priv.h" +# include "ivl_alloc.h" # include # include diff --git a/tgt-fpga/xilinx.c b/tgt-fpga/xilinx.c index 1efe9f11a..9d9d9dd08 100644 --- a/tgt-fpga/xilinx.c +++ b/tgt-fpga/xilinx.c @@ -21,6 +21,7 @@ # include "generic.h" # include "xilinx.h" # include "fpga_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-pal/emit_jed.c b/tgt-pal/emit_jed.c index 29066ba6e..ae9ad5bbc 100644 --- a/tgt-pal/emit_jed.c +++ b/tgt-pal/emit_jed.c @@ -20,6 +20,7 @@ # include "config.h" # include "priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-pal/fit_log.c b/tgt-pal/fit_log.c index 2fad89fd7..469cebad6 100644 --- a/tgt-pal/fit_log.c +++ b/tgt-pal/fit_log.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000 Stephen Williams (steve@icarus.com) + * Copyright (c) 2000-2010 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,13 +16,11 @@ * 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: fit_log.c,v 1.6 2007/02/26 19:49:50 steve Exp $" -#endif # include "config.h" # include "ivl_target.h" +# include "ivl_alloc.h" # include # include # include @@ -125,27 +123,3 @@ int fit_logic(void) return 0; } - -/* - * $Log: fit_log.c,v $ - * Revision 1.6 2007/02/26 19:49:50 steve - * Spelling fixes (larry doolittle) - * - * Revision 1.5 2002/08/12 01:35:03 steve - * conditional ident string using autoconfig. - * - * Revision 1.4 2001/07/25 03:10:50 steve - * Create a config.h.in file to hold all the config - * junk, and support gcc 3.0. (Stephan Boettcher) - * - * Revision 1.3 2001/05/16 03:55:30 steve - * Update to new LPM API for flip-flops. - * - * Revision 1.2 2001/02/07 22:22:00 steve - * ivl_target header search path fixes. - * - * Revision 1.1 2000/12/14 23:37:47 steve - * Start support for fitting the logic. - * - */ - diff --git a/tgt-pal/imain.c b/tgt-pal/imain.c index ea0ee112a..00e2937ca 100644 --- a/tgt-pal/imain.c +++ b/tgt-pal/imain.c @@ -25,6 +25,7 @@ # include "priv.h" +# include "ivl_alloc.h" # include # include # include @@ -84,7 +85,6 @@ int target_design(ivl_design_t des) /* Allocate the pin array, ready to start assigning resources. */ bind_pin = calloc(pins, sizeof (struct pal_bind_s)); - assert(bind_pin); /* Connect all the macrocells that drive pins to the pin that they drive. This doesn't yet look at the design, but is diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index acf2c215b..f6a325116 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -28,6 +28,7 @@ # include "version_tag.h" # include "config.h" # include "priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-vvp/draw_net_input.c b/tgt-vvp/draw_net_input.c index a915820b4..c5481aec3 100644 --- a/tgt-vvp/draw_net_input.c +++ b/tgt-vvp/draw_net_input.c @@ -18,6 +18,7 @@ */ # include "vvp_priv.h" +# include "ivl_alloc.h" # include # include # include @@ -640,7 +641,6 @@ static void draw_net_input_x(ivl_nexus_t nex, if (ndrivers >= adrivers) { adrivers += 4; drivers = realloc(drivers, adrivers*sizeof(ivl_nexus_ptr_t)); - assert(drivers); } drivers[ndrivers] = nptr; ndrivers += 1; diff --git a/tgt-vvp/draw_vpi.c b/tgt-vvp/draw_vpi.c index ccf4db9da..575b570ad 100644 --- a/tgt-vvp/draw_vpi.c +++ b/tgt-vvp/draw_vpi.c @@ -18,6 +18,7 @@ */ # include "vvp_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index cf3847614..67c6cac10 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -18,6 +18,7 @@ */ # include "vvp_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-vvp/modpath.c b/tgt-vvp/modpath.c index e65f629e0..ed97e5b99 100644 --- a/tgt-vvp/modpath.c +++ b/tgt-vvp/modpath.c @@ -18,6 +18,7 @@ */ # include "vvp_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 2c1836c83..64137c2fe 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -18,6 +18,7 @@ */ # include "vvp_priv.h" +# include "ivl_alloc.h" # include # include # include @@ -59,7 +60,6 @@ const char *vvp_mangle_id(const char *id) unsigned int nlen = strlen(id) + 4*(++nesc) + 1; if (out_len < nlen) { out = realloc(out, nlen); - assert(out); out_len = nlen; } if (n) { @@ -109,7 +109,6 @@ const char *vvp_mangle_name(const char *id) unsigned int nlen = strlen(id) + 2*(++nesc) + 1; if (out_len < nlen) { out = realloc(out, nlen); - assert(out); out_len = nlen; } if (n) { @@ -738,7 +737,6 @@ static void draw_udp_in_scope(ivl_net_logic_t lptr) if (i >= nudps) { udps = realloc(udps, (nudps+1)*sizeof(ivl_udp_t)); - assert(udps); udps[nudps++] = udp; draw_udp_def(udp); } diff --git a/vpi/sdf_parse.y b/vpi/sdf_parse.y index fffe03a50..397b66847 100644 --- a/vpi/sdf_parse.y +++ b/vpi/sdf_parse.y @@ -24,6 +24,7 @@ static void yyerror(const char*msg); # include "vpi_user.h" # include "sdf_parse_priv.h" # include "sdf_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/stringheap.c b/vpi/stringheap.c index a3e1d6eb6..819fdfac1 100644 --- a/vpi/stringheap.c +++ b/vpi/stringheap.c @@ -19,6 +19,7 @@ # include "sys_priv.h" # include "stringheap.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 2ea8e830f..b59a1d338 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -18,6 +18,7 @@ */ # include "sys_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index f3c1da5d8..4d0107cd7 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -18,6 +18,7 @@ */ # include "sys_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_fst.c b/vpi/sys_fst.c index 8ca1ee26f..de02f00b8 100644 --- a/vpi/sys_fst.c +++ b/vpi/sys_fst.c @@ -25,6 +25,7 @@ * This file contains the implementations of the FST related functions. */ +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index 5275a84b3..de86501be 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -26,6 +26,7 @@ * This file contains the implementations of the LXT related functions. */ +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 282f58fb5..e0228272e 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -26,6 +26,7 @@ * This file contains the implementations of the LXT2 related functions. */ +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 55a6d076a..1f66d2b00 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -18,6 +18,7 @@ */ #include "sys_priv.h" +#include "ivl_alloc.h" #include #include #include diff --git a/vpi/sys_random_mti.c b/vpi/sys_random_mti.c index c57fc7663..d4abaceaa 100644 --- a/vpi/sys_random_mti.c +++ b/vpi/sys_random_mti.c @@ -20,6 +20,7 @@ # include "sys_priv.h" # include "sys_random.h" +# include "ivl_alloc.h" # include # include # include @@ -164,4 +165,3 @@ void sys_random_mti_register() res = vpi_register_systf(&tf_data); vpip_make_systf_system_defined(res); } - diff --git a/vpi/sys_readmem.c b/vpi/sys_readmem.c index fc729c0e0..8cba60b7c 100644 --- a/vpi/sys_readmem.c +++ b/vpi/sys_readmem.c @@ -18,6 +18,7 @@ */ # include "sys_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_scanf.c b/vpi/sys_scanf.c index e40362641..e76e5e7ee 100644 --- a/vpi/sys_scanf.c +++ b/vpi/sys_scanf.c @@ -22,6 +22,7 @@ # define _SVID_SOURCE 1 # include "sys_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index bf84ecad4..9be51396a 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -24,6 +24,7 @@ * This file contains the implementations of the VCD related functions. */ +# include "ivl_alloc.h" # include # include # include diff --git a/vpi/v2005_math.c b/vpi/v2005_math.c index 057252b43..631bbc810 100644 --- a/vpi/v2005_math.c +++ b/vpi/v2005_math.c @@ -20,6 +20,7 @@ */ #include "vpi_config.h" +#include "ivl_alloc.h" #include #include #include @@ -175,12 +176,6 @@ static PLI_INT32 va_single_argument_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *ud) fun_data = malloc(sizeof(va_single_t)); - /* Check that malloc gave use some memory. */ - if (fun_data == 0) { - va_error_message(callh, "%s failed to allocate memory.\n", name); - return 0; - } - /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires one argument.\n", name); @@ -257,12 +252,6 @@ static PLI_INT32 va_double_argument_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *ud) fun_data = malloc(sizeof(va_double_t)); - /* Check that malloc gave use some memory. */ - if (fun_data == 0) { - va_error_message(callh, "%s failed to allocate memory.\n", name); - return 0; - } - /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires two arguments.\n", name); diff --git a/vpi/va_math.c b/vpi/va_math.c index 51b30c1cc..7221abd6a 100644 --- a/vpi/va_math.c +++ b/vpi/va_math.c @@ -20,6 +20,7 @@ */ #include "vpi_config.h" +#include "ivl_alloc.h" #include #include #include @@ -202,12 +203,6 @@ static PLI_INT32 va_single_argument_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *ud) fun_data = malloc(sizeof(va_single_t)); - /* Check that malloc gave use some memory. */ - if (fun_data == 0) { - va_error_message(callh, "%s failed to allocate memory.\n", name); - return 0; - } - /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires one argument.\n", name); @@ -284,12 +279,6 @@ static PLI_INT32 va_double_argument_compiletf(ICARUS_VPI_CONST PLI_BYTE8 *ud) fun_data = malloc(sizeof(va_double_t)); - /* Check that malloc gave use some memory. */ - if (fun_data == 0) { - va_error_message(callh, "%s failed to allocate memory.\n", name); - return 0; - } - /* Check that there are arguments. */ if (argv == 0) { va_error_message(callh, "%s requires two arguments.\n", name); diff --git a/vpi/vcd_priv.c b/vpi/vcd_priv.c index 9fe8c0904..ce2230391 100644 --- a/vpi/vcd_priv.c +++ b/vpi/vcd_priv.c @@ -19,6 +19,7 @@ #include "sys_priv.h" #include "vcd_priv.h" +#include "ivl_alloc.h" #include #include #include @@ -56,7 +57,6 @@ void vcd_names_add(struct vcd_names_list_s*tab, const char *name) { struct vcd_names_s *nl = (struct vcd_names_s *) malloc(sizeof(struct vcd_names_s)); - assert(nl); nl->name = strdup_sh(&name_heap, name); nl->next = tab->vcd_names_list; tab->vcd_names_list = nl; @@ -110,7 +110,6 @@ void vcd_names_sort(struct vcd_names_list_s*tab) tab->vcd_names_sorted = (const char **) realloc(tab->vcd_names_sorted, tab->sorted_names*(sizeof(const char *))); - assert(tab->vcd_names_sorted); l = tab->vcd_names_sorted + tab->sorted_names - tab->listed_names; tab->listed_names = 0; diff --git a/vvp/array.cc b/vvp/array.cc index 0258a948f..1b18175f4 100644 --- a/vvp/array.cc +++ b/vvp/array.cc @@ -26,6 +26,7 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/compile.cc b/vvp/compile.cc index fb157a399..bebf3b4c5 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -28,6 +28,7 @@ # include "vpi_priv.h" # include "parse_misc.h" # include "statistics.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/delay.cc b/vvp/delay.cc index de0dbc537..54ddaf72b 100644 --- a/vvp/delay.cc +++ b/vvp/delay.cc @@ -24,6 +24,7 @@ #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" #endif +#include "ivl_alloc.h" #include #include #include diff --git a/vvp/lexor.lex b/vvp/lexor.lex index e59210a5a..e5784d388 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -25,6 +25,7 @@ # include "parse_misc.h" # include "compile.h" # include "parse.h" +# include "ivl_alloc.h" # include # include @@ -73,7 +74,6 @@ static char* strdupnew(char const *str) [1-9][0-9]*("'b"|"'sb")[01xz]+ { yylval.vect.idx = strtoul(yytext, 0, 10); yylval.vect.text = (char*)malloc(yylval.vect.idx + 2); - assert(yylval.vect.text); char*dest = yylval.vect.text; const char*bits = strchr(yytext, '\''); diff --git a/vvp/parse.y b/vvp/parse.y index 274207098..a6b024ca8 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -22,6 +22,7 @@ # include "parse_misc.h" # include "compile.h" # include "delay.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/parse_misc.cc b/vvp/parse_misc.cc index 2bbaed7fb..966e74084 100644 --- a/vvp/parse_misc.cc +++ b/vvp/parse_misc.cc @@ -19,6 +19,7 @@ # include "parse_misc.h" # include "compile.h" +# include "ivl_alloc.h" # include # include diff --git a/vvp/stop.cc b/vvp/stop.cc index aea7c7f90..7ae821374 100644 --- a/vvp/stop.cc +++ b/vvp/stop.cc @@ -28,6 +28,7 @@ # include "vpi_priv.h" # include "vthread.h" # include "schedule.h" +# include "ivl_alloc.h" # include # include #ifdef USE_READLINE diff --git a/vvp/udp.cc b/vvp/udp.cc index 44e5d5591..f99b3aef0 100644 --- a/vvp/udp.cc +++ b/vvp/udp.cc @@ -27,6 +27,7 @@ #include "config.h" #ifdef CHECK_WITH_VALGRIND #include "vvp_cleanup.h" +#include "ivl_alloc.h" #endif #include #include diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index a7d13a2fa..6b5b5bc87 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -23,6 +23,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_event.cc b/vvp/vpi_event.cc index 7eabdb95b..0d0533396 100644 --- a/vvp/vpi_event.cc +++ b/vvp/vpi_event.cc @@ -19,6 +19,7 @@ # include "compile.h" # include "vpi_priv.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_iter.cc b/vvp/vpi_iter.cc index c0dfae410..a13a5478e 100644 --- a/vvp/vpi_iter.cc +++ b/vvp/vpi_iter.cc @@ -22,6 +22,7 @@ */ # include "vpi_priv.h" +# include "ivl_alloc.h" # include # include diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index bf8ced53a..177a7efe5 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -22,6 +22,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 9098a9d19..4a944c2d8 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2009 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2010 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 @@ -21,6 +21,7 @@ # include "vpi_priv.h" # include "ivl_dlfcn.h" # include "vvp_cleanup.h" +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index 571e6fbf4..d6907c97a 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -24,6 +24,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_scope.cc b/vvp/vpi_scope.cc index 01d78226c..4cab607de 100644 --- a/vvp/vpi_scope.cc +++ b/vvp/vpi_scope.cc @@ -25,6 +25,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_signal.cc b/vvp/vpi_signal.cc index 0ff68bf03..84379d38f 100644 --- a/vvp/vpi_signal.cc +++ b/vvp/vpi_signal.cc @@ -31,6 +31,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index 428620935..4eae82268 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -29,6 +29,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index f65d2de97..14bafe815 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -30,6 +30,7 @@ # include "vvp_cleanup.h" # include #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vpip_to_dec.cc b/vvp/vpip_to_dec.cc index 543d62461..4ea73f3aa 100644 --- a/vvp/vpip_to_dec.cc +++ b/vvp/vpip_to_dec.cc @@ -23,6 +23,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include /* for CHAR_BIT */ @@ -149,9 +150,7 @@ unsigned vpip_vec4_to_dec_str(const vvp_vector4_t&vec4, #define ALLOC_MARGIN 4 if (!valv || vlen > vlen_alloc) { if (valv) free(valv); - valv = (unsigned long*) - calloc( vlen+ALLOC_MARGIN, sizeof (*valv)); - if (!valv) {perror("malloc"); return 0; } + valv = (unsigned long*) calloc(vlen+ALLOC_MARGIN, sizeof (*valv)); vlen_alloc=vlen+ALLOC_MARGIN; } else { memset(valv,0,vlen*sizeof(valv[0])); diff --git a/vvp/vvp_island.cc b/vvp/vvp_island.cc index 1b79d932e..55d161566 100644 --- a/vvp/vvp_island.cc +++ b/vvp/vvp_island.cc @@ -25,6 +25,7 @@ #ifdef CHECK_WITH_VALGRIND # include "vvp_cleanup.h" #endif +# include "ivl_alloc.h" # include # include # include diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index 8bd6338e7..976b55cda 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -33,7 +33,8 @@ #ifdef CHECK_WITH_VALGRIND # include # include -# include "sfunc.h" +# include "sfunc.h" +# include "ivl_alloc.h" #endif permaheap vvp_net_fun_t::heap_; diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 6fb218c93..a806557ab 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -23,6 +23,7 @@ # include "vpi_user.h" # include "vvp_vpi_callback.h" # include "permaheap.h" +# include "ivl_alloc.h" # include # include # include