[Opensrf-commits] r1363 - in trunk: include/opensrf src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Jul 9 14:32:40 EDT 2008


Author: erickson
Date: 2008-07-09 14:32:37 -0400 (Wed, 09 Jul 2008)
New Revision: 1363

Modified:
   trunk/include/opensrf/utils.h
   trunk/src/libopensrf/utils.c
Log:
added a buffer_chomp function to drop the last character from the buffer

Modified: trunk/include/opensrf/utils.h
===================================================================
--- trunk/include/opensrf/utils.h	2008-07-09 16:06:01 UTC (rev 1362)
+++ trunk/include/opensrf/utils.h	2008-07-09 18:32:37 UTC (rev 1363)
@@ -195,6 +195,7 @@
 char* buffer_release( growing_buffer* gb );
 int buffer_free( growing_buffer* gb );
 int buffer_add_char(growing_buffer* gb, char c);
+int buffer_chomp(growing_buffer* gb); // removes the last character from the buffer
 
 /* returns the size needed to fill in the vsnprintf buffer.  
 	* ! this calls va_end on the va_list argument*

Modified: trunk/src/libopensrf/utils.c
===================================================================
--- trunk/src/libopensrf/utils.c	2008-07-09 16:06:01 UTC (rev 1362)
+++ trunk/src/libopensrf/utils.c	2008-07-09 18:32:37 UTC (rev 1363)
@@ -280,7 +280,16 @@
 	return strdup( gb->buf );
 }
 
+int buffer_chomp(growing_buffer* gb) {
+	if( gb == NULL ) { return -1; }
+    if(gb->n_used > 0) {
+	    gb->n_used--;
+	    gb->buf[gb->n_used] = '\0';
+    }
+    return gb->n_used;
+}
 
+
 /*
 #define OSRF_BUFFER_ADD_CHAR(gb, c)\
 	do {\



More information about the opensrf-commits mailing list