1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 09:47:17 +00:00

Run formatter.

This commit is contained in:
Calvin Rose 2019-11-28 23:26:11 -05:00
parent 688d297a18
commit 4e4cdb6356
3 changed files with 14 additions and 14 deletions

View File

@ -355,9 +355,9 @@ void *janet_gcalloc(enum JanetMemoryType type, size_t size) {
}
static void free_one_scratch(void *mem) {
ScratchFinalizer finalize = *(ScratchFinalizer*)mem;
ScratchFinalizer finalize = *(ScratchFinalizer *)mem;
if (finalize)
finalize((char*)mem + SCRATCH_HDR_SIZE);
finalize((char *)mem + SCRATCH_HDR_SIZE);
free(mem);
}
@ -472,11 +472,11 @@ void janet_gcunlock(int handle) {
/* Scratch memory API */
void *janet_smalloc(size_t size) {
void *mem = malloc(SCRATCH_HDR_SIZE+size);
void *mem = malloc(SCRATCH_HDR_SIZE + size);
if (NULL == mem) {
JANET_OUT_OF_MEMORY;
}
*(ScratchFinalizer*)mem = NULL;
*(ScratchFinalizer *)mem = NULL;
if (janet_scratch_len == janet_scratch_cap) {
size_t newcap = 2 * janet_scratch_cap + 2;
void **newmem = (void **) realloc(janet_scratch_mem, newcap * sizeof(void *));
@ -487,21 +487,21 @@ void *janet_smalloc(size_t size) {
janet_scratch_mem = newmem;
}
janet_scratch_mem[janet_scratch_len++] = mem;
return (char*)mem + SCRATCH_HDR_SIZE;
return (char *)mem + SCRATCH_HDR_SIZE;
}
void *janet_srealloc(void *mem, size_t size) {
if (NULL == mem) return janet_smalloc(size);
mem = (char*)mem - SCRATCH_HDR_SIZE;
mem = (char *)mem - SCRATCH_HDR_SIZE;
if (janet_scratch_len) {
for (size_t i = janet_scratch_len - 1; ; i--) {
if (janet_scratch_mem[i] == mem) {
void *newmem = realloc(mem, size+SCRATCH_HDR_SIZE);
void *newmem = realloc(mem, size + SCRATCH_HDR_SIZE);
if (NULL == newmem) {
JANET_OUT_OF_MEMORY;
}
janet_scratch_mem[i] = newmem;
return (char*)newmem + SCRATCH_HDR_SIZE;
return (char *)newmem + SCRATCH_HDR_SIZE;
}
if (i == 0) break;
}
@ -510,13 +510,13 @@ void *janet_srealloc(void *mem, size_t size) {
}
void janet_sfinalizer(void *mem, ScratchFinalizer finalizer) {
mem = (char*)mem - SCRATCH_HDR_SIZE;
*(ScratchFinalizer*)mem = finalizer;
mem = (char *)mem - SCRATCH_HDR_SIZE;
*(ScratchFinalizer *)mem = finalizer;
}
void janet_sfree(void *mem) {
if (NULL == mem) return;
mem = (char*)mem - SCRATCH_HDR_SIZE;
mem = (char *)mem - SCRATCH_HDR_SIZE;
if (janet_scratch_len) {
for (size_t i = janet_scratch_len - 1; ; i--) {
if (janet_scratch_mem[i] == mem) {

View File

@ -389,8 +389,8 @@ static Janet os_environ(int32_t argc, Janet *argv) {
size_t val_len = strlen(v);
janet_table_put(
t,
janet_stringv((const uint8_t*)e, full_len - val_len - 1),
janet_stringv((const uint8_t*)v, val_len)
janet_stringv((const uint8_t *)e, full_len - val_len - 1),
janet_stringv((const uint8_t *)v, val_len)
);
}
return janet_wrap_table(t);

View File

@ -1304,7 +1304,7 @@ JANET_API Janet janet_mcall(const char *name, int32_t argc, Janet *argv);
JANET_API void janet_stacktrace(JanetFiber *fiber, Janet err);
/* Scratch Memory API */
typedef void (*ScratchFinalizer)(void*);
typedef void (*ScratchFinalizer)(void *);
JANET_API void *janet_smalloc(size_t size);
JANET_API void *janet_srealloc(void *mem, size_t size);
JANET_API void janet_sfinalizer(void *mem, ScratchFinalizer finalizer);