diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-07-26 13:28:18 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-07-26 13:28:18 -0400 |
| commit | cfe46ee393aa3c9a2344a916bccfc4a69d4b8b77 (patch) | |
| tree | a5953090e0cb9c9d66b622d91012111ab30a89ea /builtins | |
| parent | 87785555eca3b7166d5f1af658a08f58a64340ed (diff) | |
Replace heap_strn() with GC_strndup()
Diffstat (limited to 'builtins')
| -rw-r--r-- | builtins/util.c | 14 | ||||
| -rw-r--r-- | builtins/util.h | 1 |
2 files changed, 2 insertions, 13 deletions
diff --git a/builtins/util.c b/builtins/util.c index f7fa9f92..598ab259 100644 --- a/builtins/util.c +++ b/builtins/util.c @@ -11,20 +11,10 @@ public bool USE_COLOR; -public char *heap_strn(const char *str, size_t len) -{ - if (!str) return NULL; - if (len == 0) return ""; - char *heaped = GC_MALLOC_ATOMIC(len + 1); - memcpy(heaped, str, len); - heaped[len] = '\0'; - return heaped; -} - public char *heap_str(const char *str) { if (!str) return NULL; - return heap_strn(str, strlen(str)); + return GC_strndup(str, strlen(str)); } public char *heap_strf(const char *fmt, ...) @@ -35,7 +25,7 @@ public char *heap_strf(const char *fmt, ...) int len = vasprintf(&tmp, fmt, args); if (len < 0) return NULL; va_end(args); - char *ret = heap_strn(tmp, (size_t)len); + char *ret = GC_strndup(tmp, (size_t)len); free(tmp); return ret; } diff --git a/builtins/util.h b/builtins/util.h index 5b71fa2b..08de9779 100644 --- a/builtins/util.h +++ b/builtins/util.h @@ -25,7 +25,6 @@ extern bool USE_COLOR; -char *heap_strn(const char *str, size_t len); char *heap_str(const char *str); char *heap_strf(const char *fmt, ...); CORD CORD_asprintf(CORD fmt, ...); |
