Commit 237389e3 authored by Ondrej Mosnacek's avatar Ondrej Mosnacek Committed by Paul Moore

selinux: specialize symtab insert and search functions

This encapsulates symtab a little better and will help with further
refactoring later.
Signed-off-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
Acked-by: default avatarStephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
parent 2c3d8dfe
...@@ -200,7 +200,7 @@ static int bool_isvalid(struct cond_bool_datum *b) ...@@ -200,7 +200,7 @@ static int bool_isvalid(struct cond_bool_datum *b)
return 1; return 1;
} }
int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp) int cond_read_bool(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct cond_bool_datum *booldatum; struct cond_bool_datum *booldatum;
...@@ -235,7 +235,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp) ...@@ -235,7 +235,7 @@ int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp)
if (rc) if (rc)
goto err; goto err;
key[len] = '\0'; key[len] = '\0';
rc = hashtab_insert(h, key, booldatum); rc = symtab_insert(s, key, booldatum);
if (rc) if (rc)
goto err; goto err;
......
...@@ -69,7 +69,7 @@ int cond_destroy_bool(void *key, void *datum, void *p); ...@@ -69,7 +69,7 @@ int cond_destroy_bool(void *key, void *datum, void *p);
int cond_index_bool(void *key, void *datum, void *datap); int cond_index_bool(void *key, void *datum, void *datap);
int cond_read_bool(struct policydb *p, struct hashtab *h, void *fp); int cond_read_bool(struct policydb *p, struct symtab *s, void *fp);
int cond_read_list(struct policydb *p, void *fp); int cond_read_list(struct policydb *p, void *fp);
int cond_write_bool(void *key, void *datum, void *ptr); int cond_write_bool(void *key, void *datum, void *ptr);
int cond_write_list(struct policydb *p, void *fp); int cond_write_list(struct policydb *p, void *fp);
......
...@@ -165,8 +165,8 @@ int mls_level_isvalid(struct policydb *p, struct mls_level *l) ...@@ -165,8 +165,8 @@ int mls_level_isvalid(struct policydb *p, struct mls_level *l)
if (!l->sens || l->sens > p->p_levels.nprim) if (!l->sens || l->sens > p->p_levels.nprim)
return 0; return 0;
levdatum = hashtab_search(&p->p_levels.table, levdatum = symtab_search(&p->p_levels,
sym_name(p, SYM_LEVELS, l->sens - 1)); sym_name(p, SYM_LEVELS, l->sens - 1));
if (!levdatum) if (!levdatum)
return 0; return 0;
...@@ -293,7 +293,7 @@ int mls_context_to_sid(struct policydb *pol, ...@@ -293,7 +293,7 @@ int mls_context_to_sid(struct policydb *pol,
*(next_cat++) = '\0'; *(next_cat++) = '\0';
/* Parse sensitivity. */ /* Parse sensitivity. */
levdatum = hashtab_search(&pol->p_levels.table, sensitivity); levdatum = symtab_search(&pol->p_levels, sensitivity);
if (!levdatum) if (!levdatum)
return -EINVAL; return -EINVAL;
context->range.level[l].sens = levdatum->level->sens; context->range.level[l].sens = levdatum->level->sens;
...@@ -312,7 +312,7 @@ int mls_context_to_sid(struct policydb *pol, ...@@ -312,7 +312,7 @@ int mls_context_to_sid(struct policydb *pol,
*rngptr++ = '\0'; *rngptr++ = '\0';
} }
catdatum = hashtab_search(&pol->p_cats.table, cur_cat); catdatum = symtab_search(&pol->p_cats, cur_cat);
if (!catdatum) if (!catdatum)
return -EINVAL; return -EINVAL;
...@@ -325,7 +325,7 @@ int mls_context_to_sid(struct policydb *pol, ...@@ -325,7 +325,7 @@ int mls_context_to_sid(struct policydb *pol,
if (rngptr == NULL) if (rngptr == NULL)
continue; continue;
rngdatum = hashtab_search(&pol->p_cats.table, rngptr); rngdatum = symtab_search(&pol->p_cats, rngptr);
if (!rngdatum) if (!rngdatum)
return -EINVAL; return -EINVAL;
...@@ -458,9 +458,10 @@ int mls_convert_context(struct policydb *oldp, ...@@ -458,9 +458,10 @@ int mls_convert_context(struct policydb *oldp,
return 0; return 0;
for (l = 0; l < 2; l++) { for (l = 0; l < 2; l++) {
levdatum = hashtab_search(&newp->p_levels.table, char *name = sym_name(oldp, SYM_LEVELS,
sym_name(oldp, SYM_LEVELS, oldc->range.level[l].sens - 1);
oldc->range.level[l].sens - 1));
levdatum = symtab_search(&newp->p_levels, name);
if (!levdatum) if (!levdatum)
return -EINVAL; return -EINVAL;
...@@ -470,8 +471,8 @@ int mls_convert_context(struct policydb *oldp, ...@@ -470,8 +471,8 @@ int mls_convert_context(struct policydb *oldp,
node, i) { node, i) {
int rc; int rc;
catdatum = hashtab_search(&newp->p_cats.table, catdatum = symtab_search(&newp->p_cats,
sym_name(oldp, SYM_CATS, i)); sym_name(oldp, SYM_CATS, i));
if (!catdatum) if (!catdatum)
return -EINVAL; return -EINVAL;
rc = ebitmap_set_bit(&newc->range.level[l].cat, rc = ebitmap_set_bit(&newc->range.level[l].cat,
......
...@@ -400,7 +400,7 @@ static int roles_init(struct policydb *p) ...@@ -400,7 +400,7 @@ static int roles_init(struct policydb *p)
if (!key) if (!key)
goto out; goto out;
rc = hashtab_insert(&p->p_roles.table, key, role); rc = symtab_insert(&p->p_roles, key, role);
if (rc) if (rc)
goto out; goto out;
...@@ -1065,7 +1065,7 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len) ...@@ -1065,7 +1065,7 @@ static int str_read(char **strp, gfp_t flags, void *fp, u32 len)
return 0; return 0;
} }
static int perm_read(struct policydb *p, struct hashtab *h, void *fp) static int perm_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct perm_datum *perdatum; struct perm_datum *perdatum;
...@@ -1088,7 +1088,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1088,7 +1088,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp)
if (rc) if (rc)
goto bad; goto bad;
rc = hashtab_insert(h, key, perdatum); rc = symtab_insert(s, key, perdatum);
if (rc) if (rc)
goto bad; goto bad;
...@@ -1098,7 +1098,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1098,7 +1098,7 @@ static int perm_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int common_read(struct policydb *p, struct hashtab *h, void *fp) static int common_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct common_datum *comdatum; struct common_datum *comdatum;
...@@ -1128,12 +1128,12 @@ static int common_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1128,12 +1128,12 @@ static int common_read(struct policydb *p, struct hashtab *h, void *fp)
goto bad; goto bad;
for (i = 0; i < nel; i++) { for (i = 0; i < nel; i++) {
rc = perm_read(p, &comdatum->permissions.table, fp); rc = perm_read(p, &comdatum->permissions, fp);
if (rc) if (rc)
goto bad; goto bad;
} }
rc = hashtab_insert(h, key, comdatum); rc = symtab_insert(s, key, comdatum);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1262,7 +1262,7 @@ static int read_cons_helper(struct policydb *p, ...@@ -1262,7 +1262,7 @@ static int read_cons_helper(struct policydb *p,
return 0; return 0;
} }
static int class_read(struct policydb *p, struct hashtab *h, void *fp) static int class_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct class_datum *cladatum; struct class_datum *cladatum;
...@@ -1300,8 +1300,8 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1300,8 +1300,8 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
goto bad; goto bad;
rc = -EINVAL; rc = -EINVAL;
cladatum->comdatum = hashtab_search(&p->p_commons.table, cladatum->comdatum = symtab_search(&p->p_commons,
cladatum->comkey); cladatum->comkey);
if (!cladatum->comdatum) { if (!cladatum->comdatum) {
pr_err("SELinux: unknown common %s\n", pr_err("SELinux: unknown common %s\n",
cladatum->comkey); cladatum->comkey);
...@@ -1309,7 +1309,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1309,7 +1309,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
} }
} }
for (i = 0; i < nel; i++) { for (i = 0; i < nel; i++) {
rc = perm_read(p, &cladatum->permissions.table, fp); rc = perm_read(p, &cladatum->permissions, fp);
if (rc) if (rc)
goto bad; goto bad;
} }
...@@ -1347,7 +1347,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1347,7 +1347,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
cladatum->default_type = le32_to_cpu(buf[0]); cladatum->default_type = le32_to_cpu(buf[0]);
} }
rc = hashtab_insert(h, key, cladatum); rc = symtab_insert(s, key, cladatum);
if (rc) if (rc)
goto bad; goto bad;
...@@ -1357,7 +1357,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1357,7 +1357,7 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int role_read(struct policydb *p, struct hashtab *h, void *fp) static int role_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct role_datum *role; struct role_datum *role;
...@@ -1404,7 +1404,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1404,7 +1404,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
goto bad; goto bad;
} }
rc = hashtab_insert(h, key, role); rc = symtab_insert(s, key, role);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1413,7 +1413,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1413,7 +1413,7 @@ static int role_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int type_read(struct policydb *p, struct hashtab *h, void *fp) static int type_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct type_datum *typdatum; struct type_datum *typdatum;
...@@ -1451,7 +1451,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1451,7 +1451,7 @@ static int type_read(struct policydb *p, struct hashtab *h, void *fp)
if (rc) if (rc)
goto bad; goto bad;
rc = hashtab_insert(h, key, typdatum); rc = symtab_insert(s, key, typdatum);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1487,7 +1487,7 @@ static int mls_read_level(struct mls_level *lp, void *fp) ...@@ -1487,7 +1487,7 @@ static int mls_read_level(struct mls_level *lp, void *fp)
return 0; return 0;
} }
static int user_read(struct policydb *p, struct hashtab *h, void *fp) static int user_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct user_datum *usrdatum; struct user_datum *usrdatum;
...@@ -1528,7 +1528,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1528,7 +1528,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
goto bad; goto bad;
} }
rc = hashtab_insert(h, key, usrdatum); rc = symtab_insert(s, key, usrdatum);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1537,7 +1537,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1537,7 +1537,7 @@ static int user_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int sens_read(struct policydb *p, struct hashtab *h, void *fp) static int sens_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct level_datum *levdatum; struct level_datum *levdatum;
...@@ -1569,7 +1569,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1569,7 +1569,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp)
if (rc) if (rc)
goto bad; goto bad;
rc = hashtab_insert(h, key, levdatum); rc = symtab_insert(s, key, levdatum);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1578,7 +1578,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1578,7 +1578,7 @@ static int sens_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int cat_read(struct policydb *p, struct hashtab *h, void *fp) static int cat_read(struct policydb *p, struct symtab *s, void *fp)
{ {
char *key = NULL; char *key = NULL;
struct cat_datum *catdatum; struct cat_datum *catdatum;
...@@ -1602,7 +1602,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1602,7 +1602,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp)
if (rc) if (rc)
goto bad; goto bad;
rc = hashtab_insert(h, key, catdatum); rc = symtab_insert(s, key, catdatum);
if (rc) if (rc)
goto bad; goto bad;
return 0; return 0;
...@@ -1611,7 +1611,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp) ...@@ -1611,7 +1611,7 @@ static int cat_read(struct policydb *p, struct hashtab *h, void *fp)
return rc; return rc;
} }
static int (*read_f[SYM_NUM]) (struct policydb *p, struct hashtab *h, void *fp) = static int (*read_f[SYM_NUM]) (struct policydb *p, struct symtab *s, void *fp) =
{ {
common_read, common_read,
class_read, class_read,
...@@ -1751,7 +1751,7 @@ u16 string_to_security_class(struct policydb *p, const char *name) ...@@ -1751,7 +1751,7 @@ u16 string_to_security_class(struct policydb *p, const char *name)
{ {
struct class_datum *cladatum; struct class_datum *cladatum;
cladatum = hashtab_search(&p->p_classes.table, name); cladatum = symtab_search(&p->p_classes, name);
if (!cladatum) if (!cladatum)
return 0; return 0;
...@@ -1770,9 +1770,9 @@ u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name) ...@@ -1770,9 +1770,9 @@ u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name)
cladatum = p->class_val_to_struct[tclass-1]; cladatum = p->class_val_to_struct[tclass-1];
comdatum = cladatum->comdatum; comdatum = cladatum->comdatum;
if (comdatum) if (comdatum)
perdatum = hashtab_search(&comdatum->permissions.table, name); perdatum = symtab_search(&comdatum->permissions, name);
if (!perdatum) if (!perdatum)
perdatum = hashtab_search(&cladatum->permissions.table, name); perdatum = symtab_search(&cladatum->permissions, name);
if (!perdatum) if (!perdatum)
return 0; return 0;
...@@ -2509,7 +2509,7 @@ int policydb_read(struct policydb *p, void *fp) ...@@ -2509,7 +2509,7 @@ int policydb_read(struct policydb *p, void *fp)
} }
for (j = 0; j < nel; j++) { for (j = 0; j < nel; j++) {
rc = read_f[i](p, &p->symtab[i].table, fp); rc = read_f[i](p, &p->symtab[i], fp);
if (rc) if (rc)
goto bad; goto bad;
} }
......
...@@ -1441,7 +1441,7 @@ static int string_to_context_struct(struct policydb *pol, ...@@ -1441,7 +1441,7 @@ static int string_to_context_struct(struct policydb *pol,
*p++ = 0; *p++ = 0;
usrdatum = hashtab_search(&pol->p_users.table, scontextp); usrdatum = symtab_search(&pol->p_users, scontextp);
if (!usrdatum) if (!usrdatum)
goto out; goto out;
...@@ -1457,7 +1457,7 @@ static int string_to_context_struct(struct policydb *pol, ...@@ -1457,7 +1457,7 @@ static int string_to_context_struct(struct policydb *pol,
*p++ = 0; *p++ = 0;
role = hashtab_search(&pol->p_roles.table, scontextp); role = symtab_search(&pol->p_roles, scontextp);
if (!role) if (!role)
goto out; goto out;
ctx->role = role->value; ctx->role = role->value;
...@@ -1469,7 +1469,7 @@ static int string_to_context_struct(struct policydb *pol, ...@@ -1469,7 +1469,7 @@ static int string_to_context_struct(struct policydb *pol,
oldc = *p; oldc = *p;
*p++ = 0; *p++ = 0;
typdatum = hashtab_search(&pol->p_types.table, scontextp); typdatum = symtab_search(&pol->p_types, scontextp);
if (!typdatum || typdatum->attribute) if (!typdatum || typdatum->attribute)
goto out; goto out;
...@@ -2024,26 +2024,26 @@ static int convert_context(struct context *oldc, struct context *newc, void *p) ...@@ -2024,26 +2024,26 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
/* Convert the user. */ /* Convert the user. */
rc = -EINVAL; rc = -EINVAL;
usrdatum = hashtab_search(&args->newp->p_users.table, usrdatum = symtab_search(&args->newp->p_users,
sym_name(args->oldp, sym_name(args->oldp,
SYM_USERS, oldc->user - 1)); SYM_USERS, oldc->user - 1));
if (!usrdatum) if (!usrdatum)
goto bad; goto bad;
newc->user = usrdatum->value; newc->user = usrdatum->value;
/* Convert the role. */ /* Convert the role. */
rc = -EINVAL; rc = -EINVAL;
role = hashtab_search(&args->newp->p_roles.table, role = symtab_search(&args->newp->p_roles,
sym_name(args->oldp, SYM_ROLES, oldc->role - 1)); sym_name(args->oldp, SYM_ROLES, oldc->role - 1));
if (!role) if (!role)
goto bad; goto bad;
newc->role = role->value; newc->role = role->value;
/* Convert the type. */ /* Convert the type. */
rc = -EINVAL; rc = -EINVAL;
typdatum = hashtab_search(&args->newp->p_types.table, typdatum = symtab_search(&args->newp->p_types,
sym_name(args->oldp, sym_name(args->oldp,
SYM_TYPES, oldc->type - 1)); SYM_TYPES, oldc->type - 1));
if (!typdatum) if (!typdatum)
goto bad; goto bad;
newc->type = typdatum->value; newc->type = typdatum->value;
...@@ -2623,7 +2623,7 @@ int security_get_user_sids(struct selinux_state *state, ...@@ -2623,7 +2623,7 @@ int security_get_user_sids(struct selinux_state *state,
goto out_unlock; goto out_unlock;
rc = -EINVAL; rc = -EINVAL;
user = hashtab_search(&policydb->p_users.table, username); user = symtab_search(&policydb->p_users, username);
if (!user) if (!user)
goto out_unlock; goto out_unlock;
...@@ -2975,7 +2975,7 @@ static int security_preserve_bools(struct selinux_state *state, ...@@ -2975,7 +2975,7 @@ static int security_preserve_bools(struct selinux_state *state,
if (rc) if (rc)
goto out; goto out;
for (i = 0; i < nbools; i++) { for (i = 0; i < nbools; i++) {
booldatum = hashtab_search(&policydb->p_bools.table, bnames[i]); booldatum = symtab_search(&policydb->p_bools, bnames[i]);
if (booldatum) if (booldatum)
booldatum->state = bvalues[i]; booldatum->state = bvalues[i];
} }
...@@ -3226,7 +3226,7 @@ int security_get_permissions(struct selinux_state *state, ...@@ -3226,7 +3226,7 @@ int security_get_permissions(struct selinux_state *state,
read_lock(&state->ss->policy_rwlock); read_lock(&state->ss->policy_rwlock);
rc = -EINVAL; rc = -EINVAL;
match = hashtab_search(&policydb->p_classes.table, class); match = symtab_search(&policydb->p_classes, class);
if (!match) { if (!match) {
pr_err("SELinux: %s: unrecognized class %s\n", pr_err("SELinux: %s: unrecognized class %s\n",
__func__, class); __func__, class);
...@@ -3365,7 +3365,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) ...@@ -3365,7 +3365,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
case AUDIT_SUBJ_USER: case AUDIT_SUBJ_USER:
case AUDIT_OBJ_USER: case AUDIT_OBJ_USER:
rc = -EINVAL; rc = -EINVAL;
userdatum = hashtab_search(&policydb->p_users.table, rulestr); userdatum = symtab_search(&policydb->p_users, rulestr);
if (!userdatum) if (!userdatum)
goto out; goto out;
tmprule->au_ctxt.user = userdatum->value; tmprule->au_ctxt.user = userdatum->value;
...@@ -3373,7 +3373,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) ...@@ -3373,7 +3373,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
case AUDIT_SUBJ_ROLE: case AUDIT_SUBJ_ROLE:
case AUDIT_OBJ_ROLE: case AUDIT_OBJ_ROLE:
rc = -EINVAL; rc = -EINVAL;
roledatum = hashtab_search(&policydb->p_roles.table, rulestr); roledatum = symtab_search(&policydb->p_roles, rulestr);
if (!roledatum) if (!roledatum)
goto out; goto out;
tmprule->au_ctxt.role = roledatum->value; tmprule->au_ctxt.role = roledatum->value;
...@@ -3381,7 +3381,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule) ...@@ -3381,7 +3381,7 @@ int selinux_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
case AUDIT_SUBJ_TYPE: case AUDIT_SUBJ_TYPE:
case AUDIT_OBJ_TYPE: case AUDIT_OBJ_TYPE:
rc = -EINVAL; rc = -EINVAL;
typedatum = hashtab_search(&policydb->p_types.table, rulestr); typedatum = symtab_search(&policydb->p_types, rulestr);
if (!typedatum) if (!typedatum)
goto out; goto out;
tmprule->au_ctxt.type = typedatum->value; tmprule->au_ctxt.type = typedatum->value;
......
...@@ -39,3 +39,12 @@ int symtab_init(struct symtab *s, unsigned int size) ...@@ -39,3 +39,12 @@ int symtab_init(struct symtab *s, unsigned int size)
return hashtab_init(&s->table, symhash, symcmp, size); return hashtab_init(&s->table, symhash, symcmp, size);
} }
int symtab_insert(struct symtab *s, char *name, void *datum)
{
return hashtab_insert(&s->table, name, datum);
}
void *symtab_search(struct symtab *s, const char *name)
{
return hashtab_search(&s->table, name);
}
...@@ -19,6 +19,9 @@ struct symtab { ...@@ -19,6 +19,9 @@ struct symtab {
int symtab_init(struct symtab *s, unsigned int size); int symtab_init(struct symtab *s, unsigned int size);
int symtab_insert(struct symtab *s, char *name, void *datum);
void *symtab_search(struct symtab *s, const char *name);
#endif /* _SS_SYMTAB_H_ */ #endif /* _SS_SYMTAB_H_ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment