| 68 | |
| 69 | |
| 70 | static 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 | |
| 93 | void string_reserve( string * self, int32_t capacity ) |
no outgoing calls
no test coverage detected