]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add k5_buf_get_space
authorGreg Hudson <ghudson@mit.edu>
Sun, 4 May 2014 19:43:35 +0000 (15:43 -0400)
committerGreg Hudson <ghudson@mit.edu>
Sat, 17 May 2014 22:45:27 +0000 (18:45 -0400)
Add a new k5_buf method to make room in the buffer for the caller to
fill in.

src/include/k5-buf.h
src/util/support/k5buf.c
src/util/support/libkrb5support-fixed.exports

index c5576a3e3294a40076cdf00d68c41bbd4033fd1a..da10fd9f4d73ea029392a0b293f25b2e20e28ff8 100644 (file)
@@ -91,6 +91,10 @@ void k5_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
 #endif
     ;
 
+/* Extend the length of buf by len and return a pointer to the reserved space,
+ * to be filled in by the caller.  Return NULL on error. */
+void *k5_buf_get_space(struct k5buf *buf, size_t len);
+
 /* Truncate BUF.  LEN must be between 0 and the existing buffer
  * length, or an assertion failure will result. */
 void k5_buf_truncate(struct k5buf *buf, size_t len);
index 778e68b39b938135ee0c739f81e43646bf30953a..c3c81b0b2c06f28f9adae8bdb57898406e4d36b1 100644 (file)
@@ -191,6 +191,16 @@ k5_buf_add_fmt(struct k5buf *buf, const char *fmt, ...)
     free(tmp);
 }
 
+void *
+k5_buf_get_space(struct k5buf *buf, size_t len)
+{
+    if (!ensure_space(buf, len))
+        return NULL;
+    buf->len += len;
+    buf->data[buf->len] = '\0';
+    return &buf->data[buf->len - len];
+}
+
 void
 k5_buf_truncate(struct k5buf *buf, size_t len)
 {
index 2f38242d91db161034595baf8eccf5f9ea80b382..f5fbe9e0cbe0db8a6fde425b2aa8502d306aee6f 100644 (file)
@@ -6,6 +6,7 @@ k5_buf_init_dynamic
 k5_buf_add
 k5_buf_add_len
 k5_buf_add_fmt
+k5_buf_get_space
 k5_buf_truncate
 k5_buf_data
 k5_buf_len