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

Function string_set_insert

v2/engine/object.c:196–229  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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