From 3b79f0183dde8e2b2694dc26da836c75640d8c5d Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 25 Sep 2009 13:14:35 +0200 Subject: Moved the useful append_str() macro from sqlite.c to eurephia_nullsafe.h --- common/eurephia_nullsafe.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'common') diff --git a/common/eurephia_nullsafe.h b/common/eurephia_nullsafe.h index 5f6b58c..22d50ed 100644 --- a/common/eurephia_nullsafe.h +++ b/common/eurephia_nullsafe.h @@ -58,6 +58,17 @@ #define strdup_nullsafe(str) (str != NULL ? strdup(str) : NULL) +/** + * 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 * -- cgit