| 195 | |
| 196 | |
| 197 | static 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 | |
| 233 | static struct hash_item * object_get_item( OBJECT * obj ) |
no test coverage detected