Add error checking definitions for malloc(), realloc() and calloc()

This patch adds defines that translate all malloc(), realloc() and calloc()
calls into ones with error checking when ivl_alloc.h is included.
This commit is contained in:
Cary R 2010-10-09 15:04:05 -07:00 committed by Stephen Williams
parent 93f84535b3
commit cb86fb15bf
69 changed files with 168 additions and 89 deletions

View File

@ -18,6 +18,7 @@
*/
# include "StringHeap.h"
# include "ivl_alloc.h"
# include <cstdlib>
# include <cstring>
# include <cassert>

View File

@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "ivl_alloc.h"
# include <vpi_user.h>
# include <veriuser.h>
# include <stdlib.h>

View File

@ -50,6 +50,7 @@ const char HELP[] =
#define MAXSIZE 4096
#include "ivl_alloc.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@ -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':

View File

@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <stdio.h>

86
ivl_alloc.h Normal file
View File

@ -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 <cstdlib>
# include <cstdio>
#else
# include <stdlib.h>
# include <stdio.h>
#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

View File

@ -20,6 +20,7 @@
# include "config.h"
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
@ -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);
}
}

View File

@ -37,6 +37,7 @@ const char NOTICE[] =
" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"
;
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>

View File

@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#include "ivl_alloc.h"
#include <vpi_user.h>
#include <acc_user.h>
#include <stdlib.h>

View File

@ -23,6 +23,7 @@
* via VPI. This is extremely ugly, so don't look after eating dinner.
*/
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <assert.h>
@ -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;

View File

@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
# include "ivl_alloc.h"
# include <veriuser.h>
# include <vpi_user.h>
# include <stdlib.h>

View File

@ -21,6 +21,7 @@
# include "util.h"
# include "parse_api.h"
# include "compiler.h"
# include "ivl_alloc.h"
# include <iostream>
# include <map>
# include <cstdlib>

View File

@ -38,6 +38,7 @@ const char NOTICE[] =
" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n"
;
# include "ivl_alloc.h"
# include <cstdio>
# include <iostream>
# include <fstream>

View File

@ -22,6 +22,7 @@
# include <iostream>
# include "netlist.h"
# include "ivl_alloc.h"
# include <sstream>
# include <cstring>
# include <string>

View File

@ -28,6 +28,7 @@
# include "PGenerate.h"
# include "PSpec.h"
# include "discipline.h"
# include "ivl_alloc.h"
# include <list>
# include <map>
# include <cassert>

View File

@ -22,6 +22,7 @@
# include <iostream>
# include "ivl_alloc.h"
# include <cstring>
# 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_);

View File

@ -21,6 +21,7 @@
# include "StringHeap.h"
# include "t-dll.h"
# include "discipline.h"
# include "ivl_alloc.h"
# include <cstdlib>
# include <cstdio>
# include <cstring>

View File

@ -19,6 +19,7 @@
# include "config.h"
# include "ivl_alloc.h"
# include <iostream>
# include <cstring>
@ -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);

View File

@ -22,6 +22,7 @@
# include <iostream>
# include "ivl_alloc.h"
# include <cstring>
# 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_);

View File

@ -21,6 +21,7 @@
# include <iostream>
# include "ivl_alloc.h"
# include <cstring>
# include <cstdio> // 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();

View File

@ -19,6 +19,7 @@
# include "device.h"
# include "fpga_priv.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <string.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "edif.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <string.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "fpga_priv.h"
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>

View File

@ -21,6 +21,7 @@
# include "generic.h"
# include "xilinx.h"
# include "fpga_priv.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <string.h>
# include <assert.h>

View File

@ -20,6 +20,7 @@
# include "config.h"
# include "priv.h"
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>

View File

@ -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 <stdio.h>
# include <stdlib.h>
# include <assert.h>
@ -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.
*
*/

View File

@ -25,6 +25,7 @@
# include "priv.h"
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <assert.h>
@ -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

View File

@ -28,6 +28,7 @@
# include "version_tag.h"
# include "config.h"
# include "priv.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <inttypes.h>
# include <string.h>

View File

@ -18,6 +18,7 @@
*/
# include "vvp_priv.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <math.h>
# include <string.h>
@ -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;

View File

@ -18,6 +18,7 @@
*/
# include "vvp_priv.h"
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "vvp_priv.h"
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "vvp_priv.h"
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "vvp_priv.h"
# include "ivl_alloc.h"
# include <stdlib.h>
# include <math.h>
# include <string.h>
@ -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);
}

View File

@ -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 <stdio.h>
# include <string.h>
# include <stdlib.h>

View File

@ -19,6 +19,7 @@
# include "sys_priv.h"
# include "stringheap.h"
# include "ivl_alloc.h"
# include <string.h>
# include <stdlib.h>
# include <assert.h>

View File

@ -18,6 +18,7 @@
*/
# include "sys_priv.h"
# include "ivl_alloc.h"
# include <assert.h>
# include <string.h>
# include <errno.h>

View File

@ -18,6 +18,7 @@
*/
# include "sys_priv.h"
# include "ivl_alloc.h"
# include <assert.h>
# include <ctype.h>
# include <errno.h>

View File

@ -25,6 +25,7 @@
* This file contains the implementations of the FST related functions.
*/
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

View File

@ -26,6 +26,7 @@
* This file contains the implementations of the LXT related functions.
*/
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

View File

@ -26,6 +26,7 @@
* This file contains the implementations of the LXT2 related functions.
*/
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

View File

@ -18,6 +18,7 @@
*/
#include "sys_priv.h"
#include "ivl_alloc.h"
#include <assert.h>
#include <ctype.h>
#include <stdlib.h>

View File

@ -20,6 +20,7 @@
# include "sys_priv.h"
# include "sys_random.h"
# include "ivl_alloc.h"
# include <assert.h>
# include <stdlib.h>
# include <math.h>
@ -164,4 +165,3 @@ void sys_random_mti_register()
res = vpi_register_systf(&tf_data);
vpip_make_systf_system_defined(res);
}

View File

@ -18,6 +18,7 @@
*/
# include "sys_priv.h"
# include "ivl_alloc.h"
# include <ctype.h>
# include <string.h>
# include <stdlib.h>

View File

@ -22,6 +22,7 @@
# define _SVID_SOURCE 1
# include "sys_priv.h"
# include "ivl_alloc.h"
# include <ctype.h>
# include <errno.h>
# include <string.h>

View File

@ -24,6 +24,7 @@
* This file contains the implementations of the VCD related functions.
*/
# include "ivl_alloc.h"
# include <stdio.h>
# include <stdlib.h>
# include <string.h>

View File

@ -20,6 +20,7 @@
*/
#include "vpi_config.h"
#include "ivl_alloc.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
@ -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);

View File

@ -20,6 +20,7 @@
*/
#include "vpi_config.h"
#include "ivl_alloc.h"
#include <assert.h>
#include <math.h>
#include <stdlib.h>
@ -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);

View File

@ -19,6 +19,7 @@
#include "sys_priv.h"
#include "vcd_priv.h"
#include "ivl_alloc.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -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;

View File

@ -26,6 +26,7 @@
#ifdef CHECK_WITH_VALGRIND
#include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstdlib>
# include <cstring>
# include <climits>

View File

@ -28,6 +28,7 @@
# include "vpi_priv.h"
# include "parse_misc.h"
# include "statistics.h"
# include "ivl_alloc.h"
# include <iostream>
# include <list>
# include <cstdlib>

View File

@ -24,6 +24,7 @@
#ifdef CHECK_WITH_VALGRIND
#include "vvp_cleanup.h"
#endif
#include "ivl_alloc.h"
#include <iostream>
#include <cstdlib>
#include <list>

View File

@ -25,6 +25,7 @@
# include "parse_misc.h"
# include "compile.h"
# include "parse.h"
# include "ivl_alloc.h"
# include <cstring>
# include <cassert>
@ -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, '\'');

View File

@ -22,6 +22,7 @@
# include "parse_misc.h"
# include "compile.h"
# include "delay.h"
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cassert>

View File

@ -19,6 +19,7 @@
# include "parse_misc.h"
# include "compile.h"
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>

View File

@ -28,6 +28,7 @@
# include "vpi_priv.h"
# include "vthread.h"
# include "schedule.h"
# include "ivl_alloc.h"
# include <cstdio>
# include <cctype>
#ifdef USE_READLINE

View File

@ -27,6 +27,7 @@
#include "config.h"
#ifdef CHECK_WITH_VALGRIND
#include "vvp_cleanup.h"
#include "ivl_alloc.h"
#endif
#include <cassert>
#include <cstdlib>

View File

@ -23,6 +23,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cstring>

View File

@ -19,6 +19,7 @@
# include "compile.h"
# include "vpi_priv.h"
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cstring>

View File

@ -22,6 +22,7 @@
*/
# include "vpi_priv.h"
# include "ivl_alloc.h"
# include <cstdlib>
# include <cassert>

View File

@ -22,6 +22,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cassert>
# include <cstdarg>
# include <cstdio>

View File

@ -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 <cstdio>
# include <cstring>
# include <sys/types.h>

View File

@ -24,6 +24,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cstring>

View File

@ -25,6 +25,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstring>
# include <cstdlib>
# include <cassert>

View File

@ -31,6 +31,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cmath>
# include <iostream>
# include <cstdio>

View File

@ -29,6 +29,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cstring>

View File

@ -30,6 +30,7 @@
# include "vvp_cleanup.h"
# include <map>
#endif
# include "ivl_alloc.h"
# include <cstdio>
# include <cstdlib>
# include <cassert>

View File

@ -23,6 +23,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <cstdio>
# include <cstring>
# include <climits> /* 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]));

View File

@ -25,6 +25,7 @@
#ifdef CHECK_WITH_VALGRIND
# include "vvp_cleanup.h"
#endif
# include "ivl_alloc.h"
# include <iostream>
# include <list>
# include <cassert>

View File

@ -33,7 +33,8 @@
#ifdef CHECK_WITH_VALGRIND
# include <valgrind/memcheck.h>
# include <map>
# include "sfunc.h"
# include "sfunc.h"
# include "ivl_alloc.h"
#endif
permaheap vvp_net_fun_t::heap_;

View File

@ -23,6 +23,7 @@
# include "vpi_user.h"
# include "vvp_vpi_callback.h"
# include "permaheap.h"
# include "ivl_alloc.h"
# include <cstddef>
# include <cstdlib>
# include <cstring>