From c1be5d66cd68fbe7491532497f14a08992024c39 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 28 Mar 2013 16:33:39 +0100 Subject: [PATCH] Use local variable in chunk_from_str() This allows using strdup() or other string functions as argument without calling them twice. --- src/libstrongswan/utils/chunk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libstrongswan/utils/chunk.h b/src/libstrongswan/utils/chunk.h index cfda6ee771..b9f2bf266e 100644 --- a/src/libstrongswan/utils/chunk.h +++ b/src/libstrongswan/utils/chunk.h @@ -191,9 +191,9 @@ static inline void chunk_clear(chunk_t *chunk) #define chunk_from_thing(thing) chunk_create((char*)&(thing), sizeof(thing)) /** - * Initialize a chunk from a static string, not containing 0-terminator + * Initialize a chunk from a string, not containing 0-terminator */ -#define chunk_from_str(str) chunk_create(str, strlen(str)) +#define chunk_from_str(str) ({char *x = (str); chunk_create(x, strlen(x));}) /** * Allocate a chunk on the heap -- 2.47.3