ref: f71eff7e308c8e7e2f30c4b8291c6364859013d2
parent: 8cb08f4c2751dab26235520448307fcdbfc257bd
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Sat Dec 28 23:02:39 EST 2024
add and use MEM_CALLOC
--- a/cvalues.c
+++ b/cvalues.c
@@ -851,7 +851,7 @@
cbuiltin(char *name, builtin_t f)
{
cvalue_t *cv;
- cv = calloc(CVALUE_NWORDS, sizeof(*cv));
+ cv = MEM_CALLOC(CVALUE_NWORDS, sizeof(*cv));
cv->type = FL(builtintype);
cv->data = &cv->_space[0];
cv->len = sizeof(value_t);
--- a/flisp.c
+++ b/flisp.c
@@ -1268,7 +1268,7 @@
{
int i;
- fl = calloc(1, sizeof(*fl));
+ fl = MEM_CALLOC(1, sizeof(*fl));
FL(scr_width) = 100;
FL(heapsize) = initial_heapsize;
--- a/plan9/platform.h
+++ b/plan9/platform.h
@@ -26,6 +26,7 @@
#define __builtin_prefetch(x)
int __builtin_clz(unsigned int x);
+#define MEM_CALLOC(n, sz) calloc((n), (sz))
#define MEM_ALLOC(n) malloc(n)
#define MEM_REALLOC(p, n) realloc((p), (n))
#define MEM_FREE(x) free(x)
--- a/posix/platform.h
+++ b/posix/platform.h
@@ -39,6 +39,7 @@
#define __os_name__ "unknown"
#endif
+#define MEM_CALLOC(n, sz) calloc((size_t)(n), (size_t)(sz))
#define MEM_ALLOC(n) malloc((size_t)(n))
#define MEM_REALLOC(p, n) realloc((p), (size_t)(n))
#define MEM_FREE(x) free(x)
--- a/types.c
+++ b/types.c
@@ -25,7 +25,7 @@
sz = ctype_sizeof(t);
}
- ft = calloc(1, sizeof(fltype_t));
+ ft = MEM_CALLOC(1, sizeof(fltype_t));
ft->type = t;
ft->numtype = NONNUMERIC;
if(issymbol(t)){
@@ -63,7 +63,7 @@
fltype_t *
define_opaque_type(value_t sym, size_t sz, cvtable_t *vtab, cvinitfunc_t init)
{
- fltype_t *ft = calloc(1, sizeof(fltype_t));
+ fltype_t *ft = MEM_CALLOC(1, sizeof(fltype_t));
ft->type = sym;
ft->numtype = NONNUMERIC;
ft->size = sz;