mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
malloc: simplify nasm_malloc code, add nasm_strcatn()
Simplify the nasm_malloc() code by moving the pointer check into a common subroutine. We can now issue a filename error even for failures like malloc(). Add support for the gcc sentinel attribute (verify that a list ends with NULL). Add a handful of safe_alloc attributes. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
@@ -264,7 +264,7 @@ size_t strnlen(const char *s, size_t maxlen);
|
||||
#ifdef HAVE_FUNC_ATTRIBUTE_MALLOC
|
||||
# define safe_alloc never_null __attribute__((malloc))
|
||||
#else
|
||||
# define safe_alloc
|
||||
# define safe_alloc never_null
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FUNC_ATTRIBUTE_ALLOC_SIZE
|
||||
@@ -277,6 +277,12 @@ size_t strnlen(const char *s, size_t maxlen);
|
||||
# define safe_realloc(s) never_null
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FUNC_ATTRIBUTE_SENTINEL
|
||||
# define end_with_null __attribute__((sentinel))
|
||||
#else
|
||||
# define end_with_null
|
||||
#endif
|
||||
|
||||
/*
|
||||
* How to tell the compiler that a function doesn't return
|
||||
*/
|
||||
|
Reference in New Issue
Block a user