MCPcopy Create free account
hub / github.com/git/git / memintern

Function memintern

hashmap.c:331–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331const void *memintern(const void *data, size_t len)
332{
333 static struct hashmap map;
334 struct pool_entry key, *e;
335
336 /* initialize string pool hashmap */
337 if (!map.tablesize)
338 hashmap_init(&map, pool_entry_cmp, NULL, 0);
339
340 /* lookup interned string in pool */
341 hashmap_entry_init(&key.ent, memhash(data, len));
342 key.len = len;
343 e = hashmap_get_entry(&map, &key, ent, data);
344 if (!e) {
345 /* not found: create it */
346 FLEX_ALLOC_MEM(e, data, data, len);
347 hashmap_entry_init(&e->ent, key.ent.hash);
348 e->len = len;
349 hashmap_add(&map, &e->ent);
350 }
351 return e->data;
352}

Callers 1

strinternFunction · 0.85

Calls 4

hashmap_initFunction · 0.85
hashmap_entry_initFunction · 0.85
memhashFunction · 0.85
hashmap_addFunction · 0.85

Tested by

no test coverage detected