MCPcopy Create free account
hub / github.com/boostorg/build / string_reserve_internal

Function string_reserve_internal

src/engine/jam_strings.cpp:70–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68
69
70static void string_reserve_internal( string * self, int32_t capacity )
71{
72 if ( self->value == self->opt )
73 {
74 self->value = (char *)BJAM_MALLOC_ATOMIC( size_t(capacity) +
75 JAM_STRING_MAGIC_SIZE );
76 self->value[ 0 ] = 0;
77 size_t opt_size = sizeof(self->opt); // Workaround sizeof in strncat warning.
78 strncat( self->value, self->opt, opt_size );
79 assert( strlen( self->value ) <= size_t(self->capacity) && "Regression test" );
80 }
81 else
82 {
83 self->value = (char *)BJAM_REALLOC( self->value, size_t(capacity) +
84 JAM_STRING_MAGIC_SIZE );
85 }
86#ifndef NDEBUG
87 memcpy( self->value + capacity, self->magic, JAM_STRING_MAGIC_SIZE );
88#endif
89 self->capacity = capacity;
90}
91
92
93void string_reserve( string * self, int32_t capacity )

Callers 2

string_reserveFunction · 0.85
maybe_reserveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected