37 lines
704 B
C
37 lines
704 B
C
#include <stdlib.h>
|
|
|
|
#include <skipstone/watch.h>
|
|
#include <skipstone/map.h>
|
|
|
|
struct _skipstone_watch {
|
|
skipstone_link *link;
|
|
skipstone_map *endpoints;
|
|
};
|
|
|
|
skipstone_watch *skipstone_watch_new(skipstone_link *link) {
|
|
skipstone_watch *watch;
|
|
|
|
if ((watch = malloc(sizeof(*watch))) == NULL) {
|
|
goto error_malloc_watch;
|
|
}
|
|
|
|
if ((watch->endpoints = skipstone_map_new()) == NULL) {
|
|
goto error_map_new_endpoints;
|
|
}
|
|
|
|
watch->link = link;
|
|
|
|
return watch;
|
|
|
|
error_map_new_endpoints:
|
|
free(watch);
|
|
|
|
error_malloc_watch:
|
|
return NULL;
|
|
}
|
|
|
|
void skipstone_watch_destroy(skipstone_watch *watch) {
|
|
skipstone_map_destroy(watch->endpoints, NULL);
|
|
|
|
free(watch);
|
|
}
|