summaryrefslogtreecommitdiff
path: root/nasmlib.h
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-07-01 22:02:54 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-07-01 22:02:54 -0700
commit807bed5ffd11a3b2cd8f8ccd8824c43ac5f5aa69 (patch)
tree660dabaffba8f02249f5232f5cde651341222566 /nasmlib.h
parent396e6dcc4b446f2b17cc5a03b8e43b1a298b9895 (diff)
downloadnasm-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.h')
-rw-r--r--nasmlib.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/nasmlib.h b/nasmlib.h
index 995c961..6776c91 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -152,14 +152,14 @@ void *nasm_zalloc(size_t);
void *nasm_realloc(void *, size_t);
void nasm_free(void *);
char *nasm_strdup(const char *);
-char *nasm_strndup(char *, size_t);
+char *nasm_strndup(const char *, size_t);
#else
-void *nasm_malloc_log(char *, int, size_t);
-void *nasm_zalloc_log(char *, int, size_t);
-void *nasm_realloc_log(char *, int, void *, size_t);
-void nasm_free_log(char *, int, void *);
-char *nasm_strdup_log(char *, int, const char *);
-char *nasm_strndup_log(char *, int, char *, size_t);
+void *nasm_malloc_log(const char *, int, size_t);
+void *nasm_zalloc_log(const char *, int, size_t);
+void *nasm_realloc_log(const char *, int, void *, size_t);
+void nasm_free_log(const char *, int, void *);
+char *nasm_strdup_log(const char *, int, const char *);
+char *nasm_strndup_log(const char *, int, const char *, size_t);
#define nasm_malloc(x) nasm_malloc_log(__FILE__,__LINE__,x)
#define nasm_zalloc(x) nasm_zalloc_log(__FILE__,__LINE__,x)
#define nasm_realloc(x,y) nasm_realloc_log(__FILE__,__LINE__,x,y)
@@ -169,6 +169,13 @@ char *nasm_strndup_log(char *, int, char *, size_t);
#endif
/*
+ * NASM assert failure
+ */
+noreturn nasm_assert_failed(const char *, int, const char *);
+#define nasm_assert(x) \
+ do { if (!(x)) nasm_assert_failed(__FILE__,__LINE__,#x); } while (0)
+
+/*
* ANSI doesn't guarantee the presence of `stricmp' or
* `strcasecmp'.
*/