Skip to content

Commit

Permalink
Rename zalloc and friends to zgc_alloc and friends. Corresponds to ll…
Browse files Browse the repository at this point in the history
…vm-project-deluge/4a5dfa36a470
  • Loading branch information
Filip Pizlo committed Jul 3, 2024
1 parent 36315e1 commit 0d818f4
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/env/__init_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ volatile int __thread_list_lock;
hidden void destroy_internal_thread_data()
{
internal_thread_data* data = get_internal_thread_data();
zfree(data->dlerror_string);
zfree(data);
zgc_free(data->dlerror_string);
zgc_free(data);
}

hidden void __init_tls(void)
Expand All @@ -34,7 +34,7 @@ hidden internal_thread_data* get_internal_thread_data(void)
hidden void set_new_internal_thread_data(void)
{
ZASSERT(!zthread_self_cookie());
internal_thread_data* data = (internal_thread_data*)zalloc(sizeof(internal_thread_data));
internal_thread_data* data = (internal_thread_data*)zgc_alloc(sizeof(internal_thread_data));
data->the_errno = 0;
data->locale = &libc.global_locale;
data->thread_locals = NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/ldso/dlerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ hidden void __dl_vseterr(const char *fmt, va_list ap)
va_copy(ap2, ap);
internal_thread_data* data = get_internal_thread_data();
if (data->dlerror_string)
zfree(data->dlerror_string);
zgc_free(data->dlerror_string);
size_t len = vsnprintf(0, 0, fmt, ap2);
if (len < sizeof(void *)) len = sizeof(void *);
va_end(ap2);
char *buf = (char*)zalloc(len+1);
char *buf = (char*)zgc_alloc(len+1);
ZASSERT(buf);
vsnprintf(buf, len+1, fmt, ap);
data->dlerror_string = buf;
Expand Down
4 changes: 2 additions & 2 deletions src/locale/locale_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const struct __locale_map *__get_locale(int cat, const char *val)
size_t map_size;
const void *map = __map_file(buf, &map_size);
if (map) {
new = zalloc(sizeof(*new));
new = zgc_alloc(sizeof(*new));
if (!new) {
__munmap((void *)map, map_size);
break;
Expand All @@ -97,7 +97,7 @@ const struct __locale_map *__get_locale(int cat, const char *val)
* object anyway to store the name, which is kept for the
* sake of being able to do message translations at the
* application level. */
if (!new && (new = zalloc(sizeof(*new)))) {
if (!new && (new = zgc_alloc(sizeof(*new)))) {
new->map = __c_dot_utf8.map;
new->map_size = __c_dot_utf8.map_size;
memcpy(new->name, val, n);
Expand Down
2 changes: 1 addition & 1 deletion src/malloc/aligned_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

void* aligned_alloc(size_t alignment, size_t size)
{
return zaligned_alloc(alignment, size);
return zgc_aligned_alloc(alignment, size);
}
2 changes: 1 addition & 1 deletion src/malloc/calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ void *calloc(size_t m, size_t n)
return 0;
}
n *= m;
return zalloc(n); /* zalloc zeroes memory alraedy */
return zgc_alloc(n); /* zgc_alloc zeroes memory alraedy */
}
4 changes: 2 additions & 2 deletions src/malloc/free.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

void free(void *p)
{
zfree(p);
zgc_free(p);
}

void __libc_free(void *p)
{
zfree(p);
zgc_free(p);
}
2 changes: 1 addition & 1 deletion src/malloc/libc_calloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void* __libc_calloc(size_t size, size_t count)
return NULL;
}

return zalloc(size); /* zalloc already zeroes memory */
return zgc_alloc(size); /* zgc_alloc already zeroes memory */
}


2 changes: 1 addition & 1 deletion src/malloc/lite_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

void *__libc_malloc(size_t n)
{
return zalloc(n);
return zgc_alloc(n);
}

2 changes: 1 addition & 1 deletion src/malloc/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

void* malloc(size_t size)
{
return zalloc(size);
return zgc_alloc(size);
}
2 changes: 1 addition & 1 deletion src/malloc/realloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

void *realloc(void *p, size_t n)
{
return zrealloc(p, n);
return zgc_realloc(p, n);
}
6 changes: 3 additions & 3 deletions src/network/freeaddrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ void freeaddrinfo(struct addrinfo *p)
{
while (p) {
struct addrinfo* next = p->ai_next;
zfree(p->ai_addr);
zfree(p->ai_canonname);
zfree(p);
zgc_free(p->ai_addr);
zgc_free(p->ai_canonname);
zgc_free(p);
p = next;
}
}
2 changes: 1 addition & 1 deletion src/stdlib/qsort.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void __qsort_r(void *base, size_t nel, size_t width, cmpfun cmp, void *arg)
head -= width;
}

zfree(tmp);
zgc_free(tmp);
}

weak_alias(__qsort_r, qsort_r);
6 changes: 3 additions & 3 deletions src/thread/pthread_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void* start(void* p)
set_new_internal_thread_data();
void* (*start_func)(void*) = args->start_func;
void* start_arg = args->start_arg;
zfree(args);
zgc_free(args);
void* result = start_func(start_arg);

internal_thread_data* data = get_internal_thread_data();
Expand Down Expand Up @@ -67,12 +67,12 @@ static void* start(void* p)
int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attrp, void *(*entry)(void *), void *restrict arg)
{
ZASSERT(!attrp);
struct start_args* args = zalloc(sizeof(struct start_args));
struct start_args* args = zgc_alloc(sizeof(struct start_args));
args->start_func = entry;
args->start_arg = arg;
void* thread = zthread_create(start, args);
if (!thread) {
zfree(args);
zgc_free(args);
return errno;
}
*res = thread;
Expand Down
2 changes: 1 addition & 1 deletion src/thread/pthread_key_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int __pthread_key_create(pthread_key_t *k, void (*dtor)(void *))
else
new_size = zlength(thread_locals) * 2;

thread_local_descriptor* new_thread_locals = zalloc(sizeof(thread_local_descriptor) * new_size);
thread_local_descriptor* new_thread_locals = zgc_alloc(sizeof(thread_local_descriptor) * new_size);
ZASSERT(zlength(new_thread_locals) == new_size);
__builtin_memcpy(new_thread_locals, thread_locals, zlength(thread_locals) * sizeof(thread_local_descriptor));

Expand Down
4 changes: 2 additions & 2 deletions src/thread/pthread_setspecific.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ int pthread_setspecific(pthread_key_t k, const void *x)
size_t new_length = zlength(thread_locals);
if ((size_t)k >= new_length)
return EINVAL;
thread_local_data* new_locals = zalloc(sizeof(thread_local_data) * new_length);
thread_local_data* new_locals = zgc_alloc(sizeof(thread_local_data) * new_length);
if (!new_locals)
return ENOMEM;
__builtin_memcpy(new_locals, data->thread_locals, zlength(data->thread_locals) * sizeof(thread_local_data));
zfree(data->thread_locals);
zgc_free(data->thread_locals);
data->thread_locals = new_locals;
ZASSERT(zlength(data->thread_locals) == new_length);
}
Expand Down

0 comments on commit 0d818f4

Please sign in to comment.