MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / intern_ptr

Function intern_ptr

util/intern_strings.c:45–71  ·  view source on GitHub ↗

Store a copy of parameter str in a hash tbl */

Source from the content-addressed store, hash-verified

43
44/* Store a copy of parameter str in a hash tbl */
45struct interned_string *intern_ptr(const char *str)
46{
47 struct interned_string *s;
48
49 pthread_once(&once, init_interned_strings);
50 Pthread_mutex_lock(&intern_lk);
51 s = hash_find_readonly(interned_strings, &str);
52 if (s == NULL) {
53 s = malloc(sizeof(struct interned_string));
54 if (s == NULL) {
55 Pthread_mutex_unlock(&intern_lk);
56 return NULL;
57 }
58 s->str = strdup(str);
59 s->ix = node_ix++;
60 s->ptr = NULL;
61 s->clptr = NULL;
62 if (s->str == NULL) {
63 free(s);
64 Pthread_mutex_unlock(&intern_lk);
65 return NULL;
66 }
67 hash_add(interned_strings, s);
68 }
69 Pthread_mutex_unlock(&intern_lk);
70 return s;
71}
72
73char *intern(const char *str)
74{

Callers 15

bdb_get_cur_lsn_str_nodeFunction · 0.85
set_repinfo_master_hostFunction · 0.85
bdb_open_intFunction · 0.85
get_seqnumFunction · 0.85
bdb_get_lsn_nodeFunction · 0.85
udp_readerFunction · 0.85
add_to_netinfo_llFunction · 0.85
create_netinfoFunction · 0.85
add_to_sanctioned_nolockFunction · 0.85
host_info_newFunction · 0.85
internFunction · 0.85

Calls 5

hash_find_readonlyFunction · 0.85
mallocFunction · 0.85
freeFunction · 0.85
hash_addFunction · 0.85
strdupFunction · 0.50

Tested by

no test coverage detected