diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-07-01 22:02:54 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-07-01 22:02:54 -0700 |
commit | 807bed5ffd11a3b2cd8f8ccd8824c43ac5f5aa69 (patch) | |
tree | 660dabaffba8f02249f5232f5cde651341222566 /nasmlib.c | |
parent | 396e6dcc4b446f2b17cc5a03b8e43b1a298b9895 (diff) | |
download | nasm-807bed5ffd11a3b2cd8f8ccd8824c43ac5f5aa69.tar.gz nasm-807bed5ffd11a3b2cd8f8ccd8824c43ac5f5aa69.tar.bz2 nasm-807bed5ffd11a3b2cd8f8ccd8824c43ac5f5aa69.zip |
nasmlib: add nasm_assert(); use const char * for filenames
Add new nasm_assert() function, and add "const" to the declarations
which take filenames, as well as to the nasm_strdup/strndup functions.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'nasmlib.c')
-rw-r--r-- | nasmlib.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -95,7 +95,7 @@ void nasm_set_malloc_error(efunc error) } #ifdef LOGALLOC -void *nasm_malloc_log(char *file, int line, size_t size) +void *nasm_malloc_log(const char *file, int line, size_t size) #else void *nasm_malloc(size_t size) #endif @@ -112,7 +112,7 @@ void *nasm_malloc(size_t size) } #ifdef LOGALLOC -void *nasm_zalloc_log(char *file, int line, size_t size) +void *nasm_zalloc_log(const char *file, int line, size_t size) #else void *nasm_zalloc(size_t size) #endif @@ -129,7 +129,7 @@ void *nasm_zalloc(size_t size) } #ifdef LOGALLOC -void *nasm_realloc_log(char *file, int line, void *q, size_t size) +void *nasm_realloc_log(const char *file, int line, void *q, size_t size) #else void *nasm_realloc(void *q, size_t size) #endif @@ -149,7 +149,7 @@ void *nasm_realloc(void *q, size_t size) } #ifdef LOGALLOC -void nasm_free_log(char *file, int line, void *q) +void nasm_free_log(const char *file, int line, void *q) #else void nasm_free(void *q) #endif @@ -163,7 +163,7 @@ void nasm_free(void *q) } #ifdef LOGALLOC -char *nasm_strdup_log(char *file, int line, const char *s) +char *nasm_strdup_log(const char *file, int line, const char *s) #else char *nasm_strdup(const char *s) #endif @@ -184,9 +184,9 @@ char *nasm_strdup(const char *s) } #ifdef LOGALLOC -char *nasm_strndup_log(char *file, int line, char *s, size_t len) +char *nasm_strndup_log(const char *file, int line, const char *s, size_t len) #else -char *nasm_strndup(char *s, size_t len) +char *nasm_strndup(const char *s, size_t len) #endif { char *p; @@ -205,6 +205,13 @@ char *nasm_strndup(char *s, size_t len) return p; } +noreturn nasm_assert_failed(const char *file, int line, const char *msg) +{ + nasm_malloc_error(ERR_FATAL, "assertion %s failed at %s:%d", + msg, file, line); + exit(1); +} + #ifndef nasm_stricmp int nasm_stricmp(const char *s1, const char *s2) { |