diff options
author | Dmitri Pal <dpal@redhat.com> | 2010-07-23 19:33:04 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-09-22 14:57:53 -0400 |
commit | ee99d5d047080218bde02e2d06e0d14518fefa4f (patch) | |
tree | 59b8ec3bd8d19dd98e78aec2de0aac74e38ffd97 /basicobjects/simplebuffer_ut.c | |
parent | 2893de11973c4912f4c2a3d40f09ef0823a3f091 (diff) | |
download | ding-libs-ee99d5d047080218bde02e2d06e0d14518fefa4f.tar.gz ding-libs-ee99d5d047080218bde02e2d06e0d14518fefa4f.tar.xz ding-libs-ee99d5d047080218bde02e2d06e0d14518fefa4f.zip |
Added a convenience function
Added a function to add a string to the buffer.
Allows adding const strings to the buffer.
This solution eliminates all the hassle of type casting
that was needed before.
Diffstat (limited to 'basicobjects/simplebuffer_ut.c')
-rw-r--r-- | basicobjects/simplebuffer_ut.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/basicobjects/simplebuffer_ut.c b/basicobjects/simplebuffer_ut.c index f94a1c0..61272da 100644 --- a/basicobjects/simplebuffer_ut.c +++ b/basicobjects/simplebuffer_ut.c @@ -43,6 +43,7 @@ int simple_test(void) struct simplebuffer *data = NULL; char str1[] = "test string 1"; char str2[] = "test string 2"; + const char str3[] = "test string 3"; uint32_t left = 0; int i; const unsigned char *buf; @@ -82,6 +83,23 @@ int simple_test(void) return error; } + error = simplebuffer_add_cr(data); + if (error) { + printf("Failed to add CR to an object %d\n", error); + simplebuffer_free(data); + return error; + } + + error = simplebuffer_add_str(data, + str3, + strlen(str3), + 1); + if (error) { + printf("Failed to add string to an object %d\n", error); + simplebuffer_free(data); + return error; + } + left = simplebuffer_get_len(data); buf = simplebuffer_get_buf(data); |