Changeset View
Changeset View
Standalone View
Standalone View
head/contrib/elftoolchain/libelftc/elftc_string_table.c
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
elftc_string_table_destroy(Elftc_String_Table *st) | elftc_string_table_destroy(Elftc_String_Table *st) | ||||
{ | { | ||||
int n; | int n; | ||||
struct _Elftc_String_Table_Entry *s, *t; | struct _Elftc_String_Table_Entry *s, *t; | ||||
for (n = 0; n < st->st_nbuckets; n++) | for (n = 0; n < st->st_nbuckets; n++) | ||||
SLIST_FOREACH_SAFE(s, &st->st_buckets[n], ste_next, t) | SLIST_FOREACH_SAFE(s, &st->st_buckets[n], ste_next, t) | ||||
free(s); | free(s); | ||||
free(st->st_string_pool); | free(st->st_string_pool); | ||||
free(st); | free(st); | ||||
return; | |||||
} | } | ||||
Elftc_String_Table * | Elftc_String_Table * | ||||
elftc_string_table_from_section(Elf_Scn *scn, int sizehint) | elftc_string_table_from_section(Elf_Scn *scn, int sizehint) | ||||
{ | { | ||||
int len; | int len; | ||||
Elf_Data *d; | Elf_Data *d; | ||||
GElf_Shdr sh; | GElf_Shdr sh; | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | elftc_string_table_insert(Elftc_String_Table *st, const char *string) | ||||
ste = elftc_string_table_find_hash_entry(st, string, &hashindex); | ste = elftc_string_table_find_hash_entry(st, string, &hashindex); | ||||
assert(hashindex >= 0 && hashindex < st->st_nbuckets); | assert(hashindex >= 0 && hashindex < st->st_nbuckets); | ||||
if (ste == NULL) { | if (ste == NULL) { | ||||
if ((ste = malloc(sizeof(*ste))) == NULL) | if ((ste = malloc(sizeof(*ste))) == NULL) | ||||
return (0); | return (0); | ||||
if ((ste->ste_idx = elftc_string_table_add_to_pool(st, | if ((ste->ste_idx = elftc_string_table_add_to_pool(st, | ||||
string)) == 0) { | string)) == 0) { | ||||
free(ste); | free(ste); | ||||
return (0); | return (0); | ||||
} | } | ||||
SLIST_INSERT_HEAD(&st->st_buckets[hashindex], ste, ste_next); | SLIST_INSERT_HEAD(&st->st_buckets[hashindex], ste, ste_next); | ||||
} | } | ||||
idx = ste->ste_idx; | idx = ste->ste_idx; | ||||
▲ Show 20 Lines • Show All 63 Lines • Show Last 20 Lines |