Boost logo

Boost-Commit :

From: grafikrobot_at_[hidden]
Date: 2007-11-27 12:57:16


Author: grafik
Date: 2007-11-27 12:57:15 EST (Tue, 27 Nov 2007)
New Revision: 41416
URL: http://svn.boost.org/trac/boost/changeset/41416

Log:
Check empty string invariants, instead of assuming all strings are allocated. And reset strings when they are freed.
Text files modified:
   trunk/tools/jam/src/strings.c | 9 +++++++++
   1 files changed, 9 insertions(+), 0 deletions(-)

Modified: trunk/tools/jam/src/strings.c
==============================================================================
--- trunk/tools/jam/src/strings.c (original)
+++ trunk/tools/jam/src/strings.c 2007-11-27 12:57:15 EST (Tue, 27 Nov 2007)
@@ -16,6 +16,14 @@
 static void assert_invariants( string* self )
 {
     int i;
+
+ if ( self->value == 0 )
+ {
+ assert( self->size == 0 );
+ assert( self->capacity == 0 );
+ assert( self->opt[0] == 0 );
+ return;
+ }
     
     assert( self->size < self->capacity );
     assert( ( self->capacity <= sizeof(self->opt) ) == ( self->value == self->opt ) );
@@ -49,6 +57,7 @@
     assert_invariants( s );
     if ( s->value != s->opt )
         BJAM_FREE( s->value );
+ string_new( s );
 }
 
 static void string_reserve_internal( string* self, size_t capacity )


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk