diff options
Diffstat (limited to 'common/eurephia_nullsafe.h')
-rw-r--r-- | common/eurephia_nullsafe.h | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/common/eurephia_nullsafe.h b/common/eurephia_nullsafe.h index 5f6b58c..5249c19 100644 --- a/common/eurephia_nullsafe.h +++ b/common/eurephia_nullsafe.h @@ -59,6 +59,17 @@ /** + * Wrapper macro, which appends a string to a destination string without exceeding the size + * of the destination buffer. + * + * @param dest Pointer to the destination buffer + * @param src Pointer to the value being concatenated to the destination string. + * @param size Size of the destination buffer + */ +#define append_str(dest, src, size) strncat(dest, src, (size - strlen_nullsafe(dest))) + + +/** * strlen() wrapper. Returns the length of a string * * @param str Input string @@ -69,10 +80,10 @@ -void *__malloc_nullsafe(eurephiaCTX *, size_t, const char *, int); +void *_malloc_nullsafe(eurephiaCTX *, size_t, const char *, int); /** - * Front-end macro for the __malloc_nullsafe() function. + * Front-end macro for the _malloc_nullsafe() function. * * @param ctx eurephiaCTX (used for debugg logging) * @param sz Size of the memory region wanted @@ -80,19 +91,19 @@ void *__malloc_nullsafe(eurephiaCTX *, size_t, const char *, int); * @return Returns a pointer to the memory region on success, otherwise NULL. * */ -#define malloc_nullsafe(ctx, sz) __malloc_nullsafe(ctx, sz, __FILE__, __LINE__) +#define malloc_nullsafe(ctx, sz) _malloc_nullsafe(ctx, sz, __FILE__, __LINE__) -void inline __free_nullsafe(eurephiaCTX *ctx, void *ptr, const char *file, int line); +void inline _free_nullsafe(eurephiaCTX *ctx, void *ptr, const char *file, int line); /** - * Front-end macro for the __free_nullsafe() function. + * Front-end macro for the __ree_nullsafe() function. * * @param ctx eurephiaCTX (used for debugg logging) * @param ptr Pointer to the memory region being freed. * */ -#define free_nullsafe(ctx, ptr) { __free_nullsafe(ctx, ptr, __FILE__, __LINE__); ptr = NULL; } +#define free_nullsafe(ctx, ptr) { _free_nullsafe(ctx, ptr, __FILE__, __LINE__); ptr = NULL; } /** |