Get rid of LLT malloc wrappers
This commit is contained in:
parent
934bf9d859
commit
248840df1f
|
@ -50,7 +50,7 @@ uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz,
|
|||
{
|
||||
uint32_t *p;
|
||||
size_t sz = ((newsz + 31) >> 5) * sizeof(uint32_t);
|
||||
p = LLT_REALLOC(b, sz);
|
||||
p = realloc(b, sz);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
if (initzero && newsz > oldsz) {
|
||||
|
|
|
@ -495,7 +495,7 @@ static size_t cvalue_struct_offs(value_t type, value_t field,
|
|||
while (iscons(fld)) {
|
||||
fsz = ctype_sizeof(car(cdr(car_(fld))), &al);
|
||||
|
||||
ssz = LLT_ALIGN(ssz, al);
|
||||
ssz = ALIGN(ssz, al);
|
||||
if (al > *palign)
|
||||
*palign = al;
|
||||
|
||||
|
@ -507,7 +507,7 @@ static size_t cvalue_struct_offs(value_t type, value_t field,
|
|||
ssz += fsz;
|
||||
fld = cdr_(fld);
|
||||
}
|
||||
return LLT_ALIGN(ssz, *palign);
|
||||
return ALIGN(ssz, *palign);
|
||||
}
|
||||
|
||||
static size_t cvalue_union_size(value_t type, int *palign)
|
||||
|
@ -525,7 +525,7 @@ static size_t cvalue_union_size(value_t type, int *palign)
|
|||
usz = fsz;
|
||||
fld = cdr_(fld);
|
||||
}
|
||||
return LLT_ALIGN(usz, *palign);
|
||||
return ALIGN(usz, *palign);
|
||||
}
|
||||
|
||||
// *palign is an output argument giving the alignment required by type
|
||||
|
|
|
@ -371,7 +371,7 @@ static value_t *alloc_words(int n)
|
|||
value_t *first;
|
||||
|
||||
assert(n > 0);
|
||||
n = LLT_ALIGN(n, 2); // only allocate multiples of 2 words
|
||||
n = ALIGN(n, 2); // only allocate multiples of 2 words
|
||||
if (__unlikely((value_t *)curheap > ((value_t *)lim) + 2 - n)) {
|
||||
gc(0);
|
||||
while ((value_t *)curheap > ((value_t *)lim) + 2 - n) {
|
||||
|
@ -618,7 +618,7 @@ void gc(int mustgrow)
|
|||
// more space to fill next time. if we grew tospace last time,
|
||||
// grow the other half of the heap this time to catch up.
|
||||
if (grew || ((lim - curheap) < (int)(heapsize / 5)) || mustgrow) {
|
||||
temp = LLT_REALLOC(tospace, heapsize * 2);
|
||||
temp = realloc(tospace, heapsize * 2);
|
||||
if (temp == NULL)
|
||||
fl_raise(memory_exception_value);
|
||||
tospace = temp;
|
||||
|
@ -2535,8 +2535,8 @@ static void lisp_init(size_t initial_heapsize)
|
|||
|
||||
heapsize = initial_heapsize;
|
||||
|
||||
fromspace = LLT_ALLOC(heapsize);
|
||||
tospace = LLT_ALLOC(heapsize);
|
||||
fromspace = malloc(heapsize);
|
||||
tospace = malloc(heapsize);
|
||||
curheap = fromspace;
|
||||
lim = curheap + heapsize - sizeof(struct cons);
|
||||
consflags = bitvector_new(heapsize / sizeof(struct cons), 1);
|
||||
|
|
|
@ -25,7 +25,7 @@ struct htable *htable_new(struct htable *h, size_t size)
|
|||
size *= 2; // 2 pointers per key/value pair
|
||||
size *= 2; // aim for 50% occupancy
|
||||
h->size = size;
|
||||
h->table = (void **)LLT_ALLOC(size * sizeof(void *));
|
||||
h->table = (void **)malloc(size * sizeof(void *));
|
||||
}
|
||||
if (h->table == NULL)
|
||||
return NULL;
|
||||
|
@ -37,7 +37,7 @@ struct htable *htable_new(struct htable *h, size_t size)
|
|||
void htable_free(struct htable *h)
|
||||
{
|
||||
if (h->table != &h->_space[0])
|
||||
LLT_FREE(h->table);
|
||||
free(h->table);
|
||||
}
|
||||
|
||||
// empty and reduce size
|
||||
|
@ -48,8 +48,7 @@ void htable_reset(struct htable *h, size_t sz)
|
|||
sz = nextipow2(sz);
|
||||
if (h->size > sz * 4 && h->size > HT_N_INLINE) {
|
||||
size_t newsz = sz * 4;
|
||||
void **newtab =
|
||||
(void **)LLT_REALLOC(h->table, newsz * sizeof(void *));
|
||||
void **newtab = (void **)realloc(h->table, newsz * sizeof(void *));
|
||||
if (newtab == NULL)
|
||||
return;
|
||||
h->size = newsz;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
else \
|
||||
newsz = sz << 2; \
|
||||
/*printf("trying to allocate %d words.\n", newsz); fflush(stdout);*/ \
|
||||
tab = (void **)LLT_ALLOC(newsz * sizeof(void *)); \
|
||||
tab = (void **)malloc(newsz * sizeof(void *)); \
|
||||
if (tab == NULL) \
|
||||
return NULL; \
|
||||
for (i = 0; i < newsz; i++) \
|
||||
|
@ -67,7 +67,7 @@
|
|||
} \
|
||||
} \
|
||||
if (ol != &h->_space[0]) \
|
||||
LLT_FREE(ol); \
|
||||
free(ol); \
|
||||
\
|
||||
sz = hash_size(h); \
|
||||
maxprobe = max_probe(sz); \
|
||||
|
|
16
c/ios.c
16
c/ios.c
|
@ -177,11 +177,11 @@ static char *_buf_realloc(struct ios *s, size_t sz)
|
|||
// if we own the buffer we're free to resize it
|
||||
// always allocate 1 bigger in case user wants to add a NUL
|
||||
// terminator after taking over the buffer
|
||||
temp = LLT_REALLOC(s->buf, sz + 1);
|
||||
temp = realloc(s->buf, sz + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
temp = LLT_ALLOC(sz + 1);
|
||||
temp = malloc(sz + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
s->ownbuf = 1;
|
||||
|
@ -578,7 +578,7 @@ void ios_close(struct ios *s)
|
|||
close(s->fd);
|
||||
s->fd = -1;
|
||||
if (s->buf != NULL && s->ownbuf && s->buf != &s->local[0])
|
||||
LLT_FREE(s->buf);
|
||||
free(s->buf);
|
||||
s->buf = NULL;
|
||||
s->size = s->maxsize = s->bpos = 0;
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ char *ios_takebuf(struct ios *s, size_t *psize)
|
|||
ios_flush(s);
|
||||
|
||||
if (s->buf == &s->local[0]) {
|
||||
buf = LLT_ALLOC(s->size + 1);
|
||||
buf = malloc(s->size + 1);
|
||||
if (buf == NULL)
|
||||
return NULL;
|
||||
if (s->size)
|
||||
|
@ -636,7 +636,7 @@ int ios_setbuf(struct ios *s, char *buf, size_t size, int own)
|
|||
s->size = nvalid;
|
||||
|
||||
if (s->buf != NULL && s->ownbuf && s->buf != &s->local[0])
|
||||
LLT_FREE(s->buf);
|
||||
free(s->buf);
|
||||
s->buf = buf;
|
||||
s->maxsize = size;
|
||||
s->ownbuf = own;
|
||||
|
@ -833,14 +833,14 @@ struct ios *ios_stderr = NULL;
|
|||
|
||||
void ios_init_stdstreams()
|
||||
{
|
||||
ios_stdin = LLT_ALLOC(sizeof(struct ios));
|
||||
ios_stdin = malloc(sizeof(struct ios));
|
||||
ios_fd(ios_stdin, STDIN_FILENO, 0, 0);
|
||||
|
||||
ios_stdout = LLT_ALLOC(sizeof(struct ios));
|
||||
ios_stdout = malloc(sizeof(struct ios));
|
||||
ios_fd(ios_stdout, STDOUT_FILENO, 0, 0);
|
||||
ios_stdout->bm = bm_line;
|
||||
|
||||
ios_stderr = LLT_ALLOC(sizeof(struct ios));
|
||||
ios_stderr = malloc(sizeof(struct ios));
|
||||
ios_fd(ios_stderr, STDERR_FILENO, 0, 0);
|
||||
ios_stderr->bm = bm_none;
|
||||
}
|
||||
|
|
|
@ -31,10 +31,6 @@
|
|||
#include "scheme_compiler_watcomc.h"
|
||||
#endif
|
||||
|
||||
#define LLT_ALLOC(n) malloc(n)
|
||||
#define LLT_REALLOC(p, n) realloc((p), (n))
|
||||
#define LLT_FREE(x) free(x)
|
||||
|
||||
#ifdef BITS64
|
||||
#define TOP_BIT 0x8000000000000000
|
||||
#define NBITS 64
|
||||
|
@ -43,7 +39,7 @@
|
|||
#define NBITS 32
|
||||
#endif
|
||||
|
||||
#define LLT_ALIGN(x, sz) (((x) + (sz - 1)) & (-sz))
|
||||
#define ALIGN(x, sz) (((x) + (sz - 1)) & (-sz))
|
||||
|
||||
extern double D_PNAN;
|
||||
extern double D_NNAN;
|
||||
|
|
Loading…
Reference in New Issue