adds ucx_buffer_to_sstr() macro

Wed, 09 May 2018 15:04:15 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 09 May 2018 15:04:15 +0200
changeset 289
a5eabd407774
parent 287
98da78a1e69a
child 290
d5d6ab809ad3

adds ucx_buffer_to_sstr() macro

src/ucx/buffer.h file | annotate | diff | comparison | revisions
--- a/src/ucx/buffer.h	Thu May 03 10:44:33 2018 +0200
+++ b/src/ucx/buffer.h	Wed May 09 15:04:15 2018 +0200
@@ -165,8 +165,8 @@
  * 
  * @param buffer the buffer to be cleared
  */
-#define ucx_buffer_clear(buffer) memset(buffer->space, 0, buffer->size); \
-        buffer->size = 0; buffer->pos = 0;
+#define ucx_buffer_clear(buffer) memset((buffer)->space, 0, (buffer)->size); \
+        (buffer)->size = 0; (buffer)->pos = 0;
 
 /**
  * Tests, if the buffer position has exceeded the buffer capacity.
@@ -262,6 +262,14 @@
  */
 size_t ucx_buffer_puts(UcxBuffer *buffer, char *str);
 
+/**
+ * Returns the complete buffer content as sstr_t.
+ * @param buffer the buffer
+ * @return the result of <code>sstrn()</code> with the buffer space and size
+ * as arguments
+ */
+#define ucx_buffer_to_sstr(buffer) sstrn((buffer)->space, (buffer)->size)
+
 #ifdef	__cplusplus
 }
 #endif

mercurial