From f0f639f1fa91e30132a4f452b580e0e20f8536d5 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 7 Jan 2023 12:48:10 -0800 Subject: [PATCH] fix for onefile FITSint, FITSuint I assumed that the complaint about macro refinition was for the two in alloc.c replacing two from hack.h from another file, but it could be that those being defined by alloc.c were interferring with the regular hack.h ones. alloc.c doesn't need them, and was also skipping an opportunity to use one of them. --- src/alloc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index ad477bd30..28023cafb 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -14,9 +14,9 @@ #include "nhlua.h" #endif -#define FITSint(x) FITSint_(x, __func__, (int) __LINE__) +/*#define FITSint(x) FITSint_(x, __func__, (int) __LINE__)*/ extern int FITSint_(LUA_INTEGER, const char *, int); -#define FITSuint(x) FITSuint_(x, __func__, (int) __LINE__) +/*#define FITSuint(x) FITSuint_(x, __func__, (int) __LINE__)*/ extern unsigned FITSuint_(unsigned long long, const char *, int); char *fmt_ptr(const genericptr) NONNULL; @@ -182,7 +182,10 @@ nhfree(genericptr_t ptr, const char *file, int line) char * nhdupstr(const char *string, const char *file, int line) { - return strcpy((char *) nhalloc(strlen(string) + 1, file, line), string); + /* we've got some info about the caller, so use it instead of __func__ */ + unsigned len = FITSuint_(strlen(string), file, line); + + return strcpy((char *) nhalloc(len + 1, file, line), string); } #undef dupstr @@ -194,7 +197,8 @@ nhdupstr(const char *string, const char *file, int line) char * dupstr(const char *string) { - unsigned len = FITSuint(strlen(string)); + unsigned len = FITSuint_(strlen(string), __func__, (int) __LINE__); + return strcpy((char *) alloc(len + 1), string); }