Use local variable in chunk_from_str()

This allows using strdup() or other string functions as argument
without calling them twice.
This commit is contained in:
Tobias Brunner
2013-06-11 11:03:12 +02:00
parent 456a31e895
commit c1be5d66cd
+2 -2
View File
@@ -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