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

Function string_set_insert

src/engine/object.c:197–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195
196
197static char const * string_set_insert( string_set * set, char const * string,
198 int const size )
199{
200 unsigned hash = hash_keyval( string, size );
201 unsigned pos = hash % set->num;
202
203 struct hash_item * result;
204
205 for ( result = set->data[ pos ]; result; result = result->header.next )
206 if ( !strncmp( result->data, string, size ) && !result->data[ size ] )
207 return result->data;
208
209 if ( set->size >= set->num )
210 {
211 string_set_resize( set );
212 pos = hash % set->num;
213 }
214
215 result = (struct hash_item *)allocate( sizeof( struct hash_header ) + size +
216 1 );
217 result->header.hash = hash;
218 result->header.next = set->data[ pos ];
219#ifndef NDEBUG
220 result->header.magic = OBJECT_MAGIC;
221#endif
222 memcpy( result->data, string, size );
223 result->data[ size ] = '\0';
224 assert( hash_keyval( result->data, size ) == result->header.hash );
225 set->data[ pos ] = result;
226 strtotal += size + 1;
227 ++set->size;
228
229 return result->data;
230}
231
232
233static struct hash_item * object_get_item( OBJECT * obj )

Callers 1

object_new_rangeFunction · 0.85

Calls 3

string_set_resizeFunction · 0.85
allocateFunction · 0.85
hash_keyvalFunction · 0.70

Tested by

no test coverage detected