From 047dbc476501f1edf0862aec8011e5a493d15e1f Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Sun, 5 Jan 2020 14:50:43 +0100 Subject: [PATCH] use only TMALLOC and TREALLOC for memory allocation --- src/frontend/com_sysinfo.c | 2 +- src/include/ngspice/dstring.h | 6 ++++-- src/misc/dstring.c | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/frontend/com_sysinfo.c b/src/frontend/com_sysinfo.c index 8d1f817c0..03f7e11d2 100644 --- a/src/frontend/com_sysinfo.c +++ b/src/frontend/com_sysinfo.c @@ -924,7 +924,7 @@ static void get_physical_processor_count(void) /* Allocate buffer to get the info */ SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX * const buf = - (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *) malloc(n_byte_buf); + (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)TMALLOC(char, n_byte_buf); if (buf == (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *) NULL) { fprintf(cp_err, "Unable to allocate a buffer of %lu bytes " diff --git a/src/include/ngspice/dstring.h b/src/include/ngspice/dstring.h index 25ad51773..65b88a9cb 100644 --- a/src/include/ngspice/dstring.h +++ b/src/include/ngspice/dstring.h @@ -8,6 +8,8 @@ #include #include #include +#include "ngspice/memory.h" + /* Error codes */ #define DS_E_OK 0 @@ -192,7 +194,7 @@ inline char *ds_free_move(DSTRING *p_ds, unsigned int opt) if (opt & DS_FREE_MOVE_OPT_FORCE_ALLOC) { /* Allocate to minimum size */ size_t n_byte_alloc = p_ds->length + 1; - char * const p_ret = (char *) malloc(n_byte_alloc); + char * const p_ret = TMALLOC(char, n_byte_alloc); if (p_ret == (char *) NULL) { return (char *) NULL; } @@ -204,7 +206,7 @@ inline char *ds_free_move(DSTRING *p_ds, unsigned int opt) if (opt & DS_FREE_MOVE_OPT_COMPACT) { /* Allocate to minimum size */ size_t n_byte_alloc = p_ds->length + 1; - char * const p_ret = (char *) realloc(p_buf_active, n_byte_alloc); + char * const p_ret = TREALLOC(char, p_buf_active, n_byte_alloc); if (p_ret == (char *) NULL) { /* Realloc to smaller size somehow failed! */ return (char *) NULL; diff --git a/src/misc/dstring.c b/src/misc/dstring.c index 3706134b4..d5cb4cac5 100644 --- a/src/misc/dstring.c +++ b/src/misc/dstring.c @@ -4,7 +4,6 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings. ----------------------------------------------------------------- */ #include #include -#include #include #include #include @@ -347,7 +346,7 @@ int ds_compact(DSTRING *p_ds) /* Else realloc the heap buffer */ { - void *p = realloc(p_ds->p_buf, n_byte_alloc_min); + void *p = TREALLOC(char, p_ds->p_buf, n_byte_alloc_min); if (p == NULL) { return DS_E_NO_MEMORY; }