Remove bay_remove()
This commit is contained in:
parent
5a03fd49e9
commit
9a4a4a0005
@ -81,28 +81,6 @@ bay_register(struct bay *bay, struct chan *chan)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
bay_remove(struct bay *bay, struct chan *chan)
|
|
||||||
{
|
|
||||||
struct bay_chan *bchan = find_bay_chan(bay, chan->name);
|
|
||||||
if (bchan == NULL) {
|
|
||||||
err("channel %s not registered", chan->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bchan->is_dirty) {
|
|
||||||
err("cannot remote bay channel %s in dirty state", chan->name);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
chan_set_dirty_cb(chan, NULL, NULL);
|
|
||||||
|
|
||||||
HASH_DEL(bay->channels, bchan);
|
|
||||||
free(bchan);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct bay_cb *
|
struct bay_cb *
|
||||||
bay_add_cb(struct bay *bay, enum bay_cb_type type,
|
bay_add_cb(struct bay *bay, enum bay_cb_type type,
|
||||||
struct chan *chan, bay_cb_func_t func, void *arg, int enabled)
|
struct chan *chan, bay_cb_func_t func, void *arg, int enabled)
|
||||||
|
@ -4,25 +4,6 @@
|
|||||||
#include "emu/bay.h"
|
#include "emu/bay.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
static void
|
|
||||||
test_remove(struct bay *bay)
|
|
||||||
{
|
|
||||||
struct chan chan;
|
|
||||||
chan_init(&chan, CHAN_SINGLE, "removeme");
|
|
||||||
|
|
||||||
if (bay_register(bay, &chan) != 0)
|
|
||||||
die("bay_register failed\n");
|
|
||||||
|
|
||||||
if (bay_find(bay, chan.name) == NULL)
|
|
||||||
die("bay_find failed\n");
|
|
||||||
|
|
||||||
if (bay_remove(bay, &chan) != 0)
|
|
||||||
die("bay_remove failed\n");
|
|
||||||
|
|
||||||
if (bay_find(bay, chan.name) != NULL)
|
|
||||||
die("bay_find didn't fail\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_duplicate(struct bay *bay)
|
test_duplicate(struct bay *bay)
|
||||||
{
|
{
|
||||||
@ -34,9 +15,6 @@ test_duplicate(struct bay *bay)
|
|||||||
|
|
||||||
if (bay_register(bay, &chan) == 0)
|
if (bay_register(bay, &chan) == 0)
|
||||||
die("bay_register didn't fail\n");
|
die("bay_register didn't fail\n");
|
||||||
|
|
||||||
if (bay_remove(bay, &chan) != 0)
|
|
||||||
die("bay_remove failed\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -83,9 +61,6 @@ test_callback(struct bay *bay)
|
|||||||
|
|
||||||
if (data != 1)
|
if (data != 1)
|
||||||
die("data didn't change after bay_propagate\n");
|
die("data didn't change after bay_propagate\n");
|
||||||
|
|
||||||
if (bay_remove(bay, &chan) != 0)
|
|
||||||
die("bay_remove failed\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
@ -93,7 +68,6 @@ int main(void)
|
|||||||
struct bay bay;
|
struct bay bay;
|
||||||
bay_init(&bay);
|
bay_init(&bay);
|
||||||
|
|
||||||
test_remove(&bay);
|
|
||||||
test_duplicate(&bay);
|
test_duplicate(&bay);
|
||||||
test_callback(&bay);
|
test_callback(&bay);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user