diff --git a/src/frontend/parse-bison.y b/src/frontend/parse-bison.y index c99466761..bc3b55af9 100644 --- a/src/frontend/parse-bison.y +++ b/src/frontend/parse-bison.y @@ -123,7 +123,7 @@ one_exp: exp: TOK_NUM { $$ = PP_mknnode($1); } - | TOK_STR { $$ = PP_mksnode($1); txfree((void*)$1); } + | TOK_STR { $$ = PP_mksnode($1); txfree($1); } | exp ',' exp { $$ = PP_mkbnode(PT_OP_COMMA, $1, $3); } | exp '+' exp { $$ = PP_mkbnode(PT_OP_PLUS, $1, $3); } @@ -139,7 +139,7 @@ exp: | '~' exp { $$ = PP_mkunode(PT_OP_NOT, $2); } | TOK_STR '(' exp ')' { $$ = PP_mkfnode($1, $3); - txfree((void*)$1); + txfree($1); if(!$$) YYABORT; } diff --git a/src/include/ngspice/cmproto.h b/src/include/ngspice/cmproto.h index 5692b5a21..89a8b3e0b 100644 --- a/src/include/ngspice/cmproto.h +++ b/src/include/ngspice/cmproto.h @@ -109,8 +109,8 @@ FILE *cm_stream_err(void); void *malloc_pj(size_t s); void *calloc_pj(size_t s1, size_t s2); -void *realloc_pj(void *ptr, size_t s); -void free_pj(void *ptr); +void *realloc_pj(const void *ptr, size_t s); +void free_pj(const void *ptr); FILE *fopen_with_path(const char *path, const char *mode); diff --git a/src/include/ngspice/dllitf.h b/src/include/ngspice/dllitf.h index 4df1822ad..e865c1d8e 100644 --- a/src/include/ngspice/dllitf.h +++ b/src/include/ngspice/dllitf.h @@ -70,11 +70,11 @@ struct coreInfo_t { /*Other stuff*/ void * ((*dllitf_malloc_pj)(size_t)); void * ((*dllitf_calloc_pj)(size_t, size_t)); - void * ((*dllitf_realloc_pj)(void *, size_t)); - void ((*dllitf_free_pj)(void *)); + void * ((*dllitf_realloc_pj)(const void *, size_t)); + void ((*dllitf_free_pj)(const void *)); void * ((*dllitf_tmalloc)(size_t)); - void * ((*dllitf_trealloc)(void *, size_t)); - void ((*dllitf_txfree)(void *)); + void * ((*dllitf_trealloc)(const void *, size_t)); + void ((*dllitf_txfree)(const void *)); }; #endif diff --git a/src/include/ngspice/memory.h b/src/include/ngspice/memory.h index fee10b991..ef259e185 100644 --- a/src/include/ngspice/memory.h +++ b/src/include/ngspice/memory.h @@ -10,8 +10,8 @@ #ifndef HAVE_LIBGC extern void *tmalloc(size_t num); -extern void *trealloc(void *str, size_t num); -extern void txfree(void *ptr); +extern void *trealloc(const void *str, size_t num); +extern void txfree(const void *ptr); #define tfree(x) (txfree(x), (x) = 0) diff --git a/src/maths/sparse/spdefs.h b/src/maths/sparse/spdefs.h index 7efe6a2a8..9ff853183 100644 --- a/src/maths/sparse/spdefs.h +++ b/src/maths/sparse/spdefs.h @@ -366,8 +366,8 @@ typedef struct /* Allocation */ extern void * tmalloc(size_t); -extern void txfree(void *); -extern void * trealloc(void *, size_t); +extern void txfree(const void *); +extern void * trealloc(const void *, size_t); #define SP_MALLOC(type,number) (type *) tmalloc((size_t)(number) * sizeof(type)) #define SP_REALLOC(ptr,type,number) \ diff --git a/src/misc/alloc.c b/src/misc/alloc.c index 7f4d5e548..76d171cca 100644 --- a/src/misc/alloc.c +++ b/src/misc/alloc.c @@ -85,7 +85,7 @@ tmalloc(size_t num) void * -trealloc(void *ptr, size_t num) +trealloc(const void *ptr, size_t num) { void *s; /*saj*/ @@ -95,7 +95,7 @@ trealloc(void *ptr, size_t num) #endif if (!num) { if (ptr) - free(ptr); + free((void*) ptr); return NULL; } @@ -108,7 +108,7 @@ trealloc(void *ptr, size_t num) #elif defined SHARED_MODULE mutex_lock(&allocMutex); #endif - s = realloc(ptr, num); + s = realloc((void*) ptr, num); /*saj*/ #ifdef TCL_MODULE Tcl_MutexUnlock(alloc); @@ -129,7 +129,7 @@ trealloc(void *ptr, size_t num) void -txfree(void *ptr) +txfree(const void *ptr) { /*saj*/ #ifdef TCL_MODULE @@ -141,7 +141,7 @@ txfree(void *ptr) mutex_lock(&allocMutex); #endif if (ptr) - free(ptr); + free((void*) ptr); /*saj*/ #ifdef TCL_MODULE Tcl_MutexUnlock(alloc); diff --git a/src/misc/alloc.h b/src/misc/alloc.h index 083106c4d..b310e3cba 100644 --- a/src/misc/alloc.h +++ b/src/misc/alloc.h @@ -8,8 +8,8 @@ #ifndef HAVE_LIBGC void * tmalloc(size_t num); -void * trealloc(void *ptr, size_t num); -void txfree(void *ptr); +void * trealloc(const void *ptr, size_t num); +void txfree(const void *ptr); #endif #endif diff --git a/src/spicelib/parser/inpptree-parser.y b/src/spicelib/parser/inpptree-parser.y index f52dec2f2..0c6bccadf 100644 --- a/src/spicelib/parser/inpptree-parser.y +++ b/src/spicelib/parser/inpptree-parser.y @@ -84,7 +84,7 @@ expression: exp exp: TOK_NUM { $$ = PT_mknnode($1); } - | TOK_STR { $$ = PT_mksnode($1, ckt); txfree((void*)$1); } + | TOK_STR { $$ = PT_mksnode($1, ckt); txfree($1); } | exp '+' exp { $$ = PT_mkbnode("+", $1, $3); } | exp '-' exp { $$ = PT_mkbnode("-", $1, $3); } @@ -100,7 +100,7 @@ exp: | TOK_STR '(' nonempty_arglist ')' { $$ = PT_mkfnode($1, $3); if (!$$) YYERROR; - txfree((void*)$1); } + txfree($1); } | TOK_pnode diff --git a/src/xspice/cm/cmexport.c b/src/xspice/cm/cmexport.c index 5dabf80bd..cf16cbbe0 100644 --- a/src/xspice/cm/cmexport.c +++ b/src/xspice/cm/cmexport.c @@ -9,7 +9,7 @@ static void *tcalloc(size_t a, size_t b) { } #ifdef HAVE_LIBGC -static void no_free(void *p) { +static void no_free(const void *p) { NG_IGNORE(p); } #endif diff --git a/src/xspice/cmpp/pp_lst.c b/src/xspice/cmpp/pp_lst.c index da11fb339..257bb3581 100644 --- a/src/xspice/cmpp/pp_lst.c +++ b/src/xspice/cmpp/pp_lst.c @@ -53,11 +53,6 @@ NON-STANDARD FEATURES #include -/* -void *malloc(unsigned size); -void *realloc(void *ptr, unsigned size); -*/ - /* *********************************************************************** */ /* diff --git a/src/xspice/enh/enhtrans.c b/src/xspice/enh/enhtrans.c index 954ec28a3..de5b4eee6 100644 --- a/src/xspice/enh/enhtrans.c +++ b/src/xspice/enh/enhtrans.c @@ -40,10 +40,6 @@ NON-STANDARD FEATURES /*=== FUNCTION PROTOTYPES ===*/ -//void free(void *); //ka removed compiler error -/* int atoi(char *); */ - - /*=== INCLUDE FILES ===*/ diff --git a/src/xspice/icm/dlmain.c b/src/xspice/icm/dlmain.c index ab228ca0b..75b1ab341 100644 --- a/src/xspice/icm/dlmain.c +++ b/src/xspice/icm/dlmain.c @@ -67,8 +67,8 @@ extern CM_EXPORT void *CMudnNum(void); extern CM_EXPORT void *CMgetCoreItfPtr(void); extern void *tmalloc(size_t num); -extern void *trealloc(void *str, size_t num); -extern void txfree(void *ptr); +extern void *trealloc(const void *str, size_t num); +extern void txfree(const void *ptr); // This one returns the device table @@ -386,11 +386,11 @@ void * calloc_pj(size_t s1, size_t s2) { return (coreitf->dllitf_calloc_pj)(s1,s2); } -void * realloc_pj(void *ptr, size_t s) { +void * realloc_pj(const void *ptr, size_t s) { return (coreitf->dllitf_realloc_pj)(ptr,s); } -void free_pj(void *ptr) { +void free_pj(const void *ptr) { (coreitf->dllitf_free_pj)(ptr); } @@ -398,11 +398,11 @@ void * tmalloc(size_t s) { return (coreitf->dllitf_tmalloc)(s); } -void * trealloc(void *ptr, size_t s) { +void * trealloc(const void *ptr, size_t s) { return (coreitf->dllitf_trealloc)(ptr,s); } -void txfree(void *ptr) { +void txfree(const void *ptr) { (coreitf->dllitf_txfree)(ptr); } diff --git a/src/xspice/xspice.c b/src/xspice/xspice.c index bfd277710..c43d58f0a 100644 --- a/src/xspice/xspice.c +++ b/src/xspice/xspice.c @@ -8,7 +8,7 @@ static void *tcalloc(size_t a, size_t b) { return tmalloc(a*b); /* FIXME, tcalloc must zero !?!? */ } -static void no_free(void *p) { +static void no_free(const void *p) { NG_IGNORE(p); }