Add a chunk_from_str() initializer that does not include 0-terminator
authorMartin Willi <martin@revosec.ch>
Thu, 3 Jan 2013 13:09:05 +0000 (14:09 +0100)
committerMartin Willi <martin@revosec.ch>
Fri, 15 Mar 2013 09:36:33 +0000 (10:36 +0100)
src/libstrongswan/utils/chunk.h

index 67848ee..bc14b73 100644 (file)
@@ -191,6 +191,11 @@ 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
+ */
+#define chunk_from_str(str) chunk_create(str, strlen(str))
+
+/**
  * Allocate a chunk on the heap
  */
 #define chunk_alloc(bytes) ({size_t x = (bytes); chunk_create(x ? malloc(x) : NULL, x);})