MCPcopy Index your code
hub / github.com/git/git / create_entry

Function create_entry

strmap.c:80–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80static struct strmap_entry *create_entry(struct strmap *map,
81 const char *str,
82 void *data)
83{
84 struct strmap_entry *entry;
85
86 if (map->strdup_strings) {
87 if (!map->pool) {
88 FLEXPTR_ALLOC_STR(entry, key, str);
89 } else {
90 size_t len = st_add(strlen(str), 1); /* include NUL */
91 entry = mem_pool_alloc(map->pool,
92 st_add(sizeof(*entry), len));
93 memcpy(entry + 1, str, len);
94 entry->key = (void *)(entry + 1);
95 }
96 } else if (!map->pool) {
97 entry = xmalloc(sizeof(*entry));
98 } else {
99 entry = mem_pool_alloc(map->pool, sizeof(*entry));
100 }
101 hashmap_entry_init(&entry->ent, strhash(str));
102 if (!map->strdup_strings)
103 entry->key = str;
104 entry->value = data;
105 return entry;
106}
107
108void *strmap_put(struct strmap *map, const char *str, void *data)
109{

Callers 2

strmap_putFunction · 0.70
strset_addFunction · 0.70

Calls 5

st_addFunction · 0.85
mem_pool_allocFunction · 0.85
hashmap_entry_initFunction · 0.85
strhashFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected