Rizin
unix-like reverse engineering framework and cli tools
str_constpool.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2019 thestr4ng3r <info@florianmaerkl.de>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
5 
6 static void kv_fini(HtPPKv *kv) {
7  free(kv->key);
8 }
9 
11  pool->ht = ht_pp_new(NULL, kv_fini, NULL);
12  return pool->ht != NULL;
13 }
14 
16  ht_pp_free(pool->ht);
17 }
18 
19 RZ_API const char *rz_str_constpool_get(RzStrConstPool *pool, const char *str) {
20  if (!str) {
21  return NULL;
22  }
23  HtPPKv *kv = ht_pp_find_kv(pool->ht, str, NULL);
24  if (kv) {
25  return kv->key;
26  }
27  ht_pp_insert(pool->ht, str, NULL);
28  kv = ht_pp_find_kv(pool->ht, str, NULL);
29  if (kv) {
30  return kv->key;
31  }
32  return NULL;
33 }
#define RZ_API
#define NULL
Definition: cris-opc.c:27
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
RZ_API const char * rz_str_constpool_get(RzStrConstPool *pool, const char *str)
Definition: str_constpool.c:19
static void kv_fini(HtPPKv *kv)
Definition: str_constpool.c:6
RZ_API void rz_str_constpool_fini(RzStrConstPool *pool)
Definition: str_constpool.c:15
RZ_API bool rz_str_constpool_init(RzStrConstPool *pool)
Definition: str_constpool.c:10