]> git.lizzy.rs Git - nothing.git/commitdiff
(#478) replace all calloc instance with nth_calloc
authorrexim <reximkut@gmail.com>
Tue, 6 Nov 2018 02:38:00 +0000 (09:38 +0700)
committerrexim <reximkut@gmail.com>
Tue, 6 Nov 2018 02:38:00 +0000 (09:38 +0700)
src/system/nth_alloc.c
src/ui/console_log.c
src/ui/history.c

index bd7dc352ae89b2f9cab9662d5e408253c7e67541..8ccdaad2e03215d53886f5e1c5dcd9906ec8b7b5 100644 (file)
@@ -14,7 +14,6 @@ void *nth_alloc(size_t size)
     return mem;
 }
 
-/* TODO(#478): all instances of calloc should be replaced with nth_calloc (except ebisp) */
 void *nth_calloc(size_t num, size_t size)
 {
     void *mem = calloc(num, size);
index 774a0bcdc16bc072532846859c02159579c772e0..bc0aaa5868b095f7778c800bb2e8e138afed9bd8 100644 (file)
@@ -43,13 +43,13 @@ Console_Log *create_console_log(const Sprite_font *font,
     console_log->font_size = font_size;
     console_log->capacity = capacity;
 
-    console_log->buffer = PUSH_LT(lt, calloc(capacity, sizeof(char*)), free);
+    console_log->buffer = PUSH_LT(lt, nth_calloc(capacity, sizeof(char*)), free);
     if (console_log->buffer == NULL) {
         throw_error(ERROR_TYPE_LIBC);
         RETURN_LT(lt, NULL);
     }
 
-    console_log->colors = PUSH_LT(lt, calloc(capacity, sizeof(Color)), free);
+    console_log->colors = PUSH_LT(lt, nth_calloc(capacity, sizeof(Color)), free);
     if (console_log->colors == NULL) {
         throw_error(ERROR_TYPE_LIBC);
         RETURN_LT(lt, NULL);
index 2924d3ff16d192d7d047ebf0d533f96c6f80376d..645fc5599943d13866a53aa42b993465c72eb56e 100644 (file)
@@ -39,7 +39,7 @@ History *create_history(size_t capacity)
     history->begin = 0;
     history->cursor = 0;
 
-    history->buffer = PUSH_LT(lt, calloc(capacity, sizeof(char*)), free);
+    history->buffer = PUSH_LT(lt, nth_calloc(capacity, sizeof(char*)), free);
     if (history->buffer == NULL) {
         throw_error(ERROR_TYPE_LIBC);
         RETURN_LT(lt, NULL);