starting to add code for name bindings
This commit is contained in:
parent
15fc99b8c8
commit
55970b1baf
8 changed files with 131 additions and 59 deletions
40
src/spho/bind.c
Normal file
40
src/spho/bind.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <sys/queue.h>
|
||||
|
||||
#include "spho/ctx.h"
|
||||
#include "spho/bind.h"
|
||||
|
||||
struct spho_bind *
|
||||
spho_bind_create(struct spho_ctx *ctx, struct spho_bind *parent)
|
||||
{
|
||||
struct spho_bind *bind;
|
||||
|
||||
if ((bind = malloc(sizeof(*bind))) == NULL) {
|
||||
SPHO_ERR(ctx, SPHO_ERR_SYS);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
STAILQ_INIT(&bind->head);
|
||||
bind->ctx = ctx;
|
||||
bind->parent = parent;
|
||||
|
||||
return (bind);
|
||||
}
|
||||
|
||||
int
|
||||
spho_bind_add(struct spho_bind *bind, struct spho_nom *nom, struct spho_tp *tp)
|
||||
{
|
||||
struct spho_binding *b;
|
||||
|
||||
if ((b = malloc(sizeof(*b))) == NULL) {
|
||||
SPHO_ERR(bind->ctx, SPHO_ERR_SYS);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
b->nom = nom;
|
||||
b->tp = tp;
|
||||
|
||||
STAILQ_INSERT_TAIL(&bind->head, b, entries);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue