[28324] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Add k5_buf_get_space

daemon@ATHENA.MIT.EDU (Greg Hudson)
Sat May 17 19:54:34 2014

Date: Sat, 17 May 2014 19:54:28 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201405172354.s4HNsSpw024996@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/ccd989bdc2656b153bc226462e0c13800810ae04
commit ccd989bdc2656b153bc226462e0c13800810ae04
Author: Greg Hudson <ghudson@mit.edu>
Date:   Sun May 4 15:43:35 2014 -0400

    Add k5_buf_get_space
    
    Add a new k5_buf method to make room in the buffer for the caller to
    fill in.

 src/include/k5-buf.h                          |    4 ++++
 src/util/support/k5buf.c                      |   10 ++++++++++
 src/util/support/libkrb5support-fixed.exports |    1 +
 3 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/include/k5-buf.h b/src/include/k5-buf.h
index c5576a3..da10fd9 100644
--- a/src/include/k5-buf.h
+++ b/src/include/k5-buf.h
@@ -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);
diff --git a/src/util/support/k5buf.c b/src/util/support/k5buf.c
index 778e68b..c3c81b0 100644
--- a/src/util/support/k5buf.c
+++ b/src/util/support/k5buf.c
@@ -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)
 {
diff --git a/src/util/support/libkrb5support-fixed.exports b/src/util/support/libkrb5support-fixed.exports
index 2f38242..f5fbe9e 100644
--- a/src/util/support/libkrb5support-fixed.exports
+++ b/src/util/support/libkrb5support-fixed.exports
@@ -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
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post