1. A minor streamlining of va_list_to_string(), to eliminate
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 3 Sep 2009 12:34:42 +0000 (12:34 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Thu, 3 Sep 2009 12:34:42 +0000 (12:34 +0000)
a layer of copying.

2. Corrected some faulty comments for doxygen.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1765 9efc2488-bf62-4759-914b-345cdb29e865

include/opensrf/utils.h
src/libopensrf/utils.c

index c259b7d..b98920a 100644 (file)
@@ -46,8 +46,8 @@ extern "C" {
 #include "md5.h"
 /**
        @brief Macro version of safe_malloc()
-       @param Pointer to be updated to point to newly allocated memory
-       @param How many bytes to allocate
+       @param ptr Pointer to be updated to point to newly allocated memory
+       @param size How many bytes to allocate
 */
 #define OSRF_MALLOC(ptr, size) \
        do {\
@@ -155,7 +155,7 @@ extern "C" {
 
 /**
        @brief Resolves to a const pointer to the string inside a growing_buffer
-       @param Pointer to a growing_buffier
+       @param x Pointer to a growing_buffier
 */
 #define OSRF_BUFFER_C_STR( x ) ((const char *) (x)->buf)
 
index 358dd27..79e6d0f 100644 (file)
@@ -236,17 +236,15 @@ char* va_list_to_string(const char* format, ...) {
        va_list a_copy;
 
        va_copy(a_copy, args);
-
        va_start(args, format);
-       len = va_list_size(format, args);
 
-       char buf[len];
-       osrf_clearbuf(buf, sizeof(buf));
+       char* buf = safe_malloc( va_list_size(format, args) );
+       *buf = '\0';
 
        va_start(a_copy, format);
        vsnprintf(buf, len - 1, format, a_copy);
        va_end(a_copy);
-       return strdup(buf);
+       return buf;
 }
 
 // ---------------------------------------------------------------------------------
@@ -286,6 +284,7 @@ growing_buffer* buffer_init(int num_initial_bytes) {
 /**
        @brief Allocate more memory for a growing_buffer.
        @param gb A pointer to the growing_buffer.
+       @param total_len How much total memory we need for the buffer.
        @return 0 if successful, or 1 if not.
 
        This function fails if it is asked to allocate BUFFER_MAX_SIZE
@@ -477,7 +476,7 @@ char* buffer_data( const growing_buffer *gb) {
 /**
        @brief Remove the last character from a growing_buffer.
        @param gb A pointer to the growing_buffer.
-       @return The character removed (or '\0' if the string is already empty).
+       @return The character removed (or a nul byte if the string is already empty).
 */
 char buffer_chomp(growing_buffer* gb) {
        char c = '\0';
@@ -496,7 +495,7 @@ char buffer_chomp(growing_buffer* gb) {
        @param c The character to be appended.
        @return The length of the resulting string.
 
-       If the character appended is a nul byte (i.e. '\0') it will still be appended as if
+       If the character appended is a nul byte it will still be appended as if
        it were a normal character.  The results are likely to be unpleasant.
 */
 int buffer_add_char(growing_buffer* gb, char c ) {