From e62b5e5f89e042b6d7d772776e5c71d0ef1bbb3d Mon Sep 17 00:00:00 2001 From: Trent Huber Date: Sun, 16 Nov 2025 05:03:24 -0500 Subject: [PATCH] New allocate() signature from cbs --- build.h | 2 +- external/cbs | 2 +- external/cbsfile.c | 2 +- src/cbs.h | 2 +- src/main.c | 2 +- src/options.c | 2 +- src/xpm.c | 8 ++++---- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.h b/build.h index e87a95d..acdf8eb 100644 --- a/build.h +++ b/build.h @@ -1,5 +1,5 @@ // Rebuild with the following #define to use Raylib as a dynamic library -// #define DYNAMICLIBS +#define DYNAMICLIBS #ifdef __APPLE__ #define LFRAYLIB \ diff --git a/external/cbs b/external/cbs index 011c66e..d6f96a0 160000 --- a/external/cbs +++ b/external/cbs @@ -1 +1 @@ -Subproject commit 011c66e9c2332506752b701fdfa37739dde67f6a +Subproject commit d6f96a0fa0b51e77492eee931de23021f69326a1 diff --git a/external/cbsfile.c b/external/cbsfile.c index e4657e8..4e9453f 100644 --- a/external/cbsfile.c +++ b/external/cbsfile.c @@ -17,7 +17,7 @@ void buildfiles(struct cbsfile *files) { compile(files[i].name); } - names = allocate((i + 1) * sizeof *names); + names = allocate(i + 1, sizeof*names); for (i = 0; files[i].name; ++i) names[i] = files[i].name; lflags = target->flags; diff --git a/src/cbs.h b/src/cbs.h index 0c6593b..d77f220 100644 --- a/src/cbs.h +++ b/src/cbs.h @@ -9,6 +9,6 @@ extern char **cflags, **lflags; -void *allocate(size_t s); +void *allocate(size_t num, size_t size); void compile(char *src); void load(char type, char *target, char **objs); diff --git a/src/main.c b/src/main.c index 3eabce0..af675e2 100644 --- a/src/main.c +++ b/src/main.c @@ -21,7 +21,7 @@ static void handleinput(void) { if (IsFileDropped()) { files = LoadDroppedFiles(); if (xpm) free(xpm); - xpm = allocate(FILENAME_MAX); + xpm = allocate(FILENAME_MAX, sizeof*xpm); strcpy(xpm, files.paths[0]); UnloadDroppedFiles(files); texture = reloadtexture(xpm, mode); diff --git a/src/options.c b/src/options.c index f8516cc..63f9bba 100644 --- a/src/options.c +++ b/src/options.c @@ -33,7 +33,7 @@ int options(int argc, char **argv) { debug = 1; break; case 'f': - xpm = allocate(FILENAME_MAX); + xpm = allocate(FILENAME_MAX, sizeof*xpm); strcpy(xpm, optarg); break; case 'h': diff --git a/src/xpm.c b/src/xpm.c index 7a2ead1..5ad3e6b 100644 --- a/src/xpm.c +++ b/src/xpm.c @@ -47,7 +47,7 @@ static char *arrname(char *p, size_t l) { start = p; for (; !space(*p) && *p != '['; ++p, --l) if (l == 0) return NULL; l = p - start; - r = allocate(l + 1); + r = allocate(l + 1, sizeof*r); strncpy(r, start, l); return r; @@ -158,8 +158,8 @@ static void parse(char **data, long *sizep) { } /* Colors */ - chars = allocate(ncolors * cpp * sizeof*chars); - colors = allocate(NUMMODES * ncolors * sizeof*colors); + chars = allocate(ncolors * cpp, sizeof*chars); + colors = allocate(NUMMODES * ncolors, sizeof*colors); for (i = 0; i < ncolors; ++i) { p = data[1 + i]; strncpy(chars + i * cpp, p, cpp); @@ -179,7 +179,7 @@ static void parse(char **data, long *sizep) { } /* Pixels */ - pixels = allocate(NUMMODES * height * width * sizeof*pixels); + pixels = allocate(NUMMODES * height * width, sizeof*pixels); j = width; l = 0; for (i = 0, pp = &data[1 + ncolors]; -- 2.51.0