use only TMALLOC and TREALLOC for memory allocation
This commit is contained in:
parent
5dfdf88ccc
commit
047dbc4765
|
|
@ -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 "
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#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;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ DESCRIPTION:This file contains the routines for manipulating dynamic strings.
|
|||
----------------------------------------------------------------- */
|
||||
#include <ctype.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue