summaryrefslogtreecommitdiff
path: root/src/set.c
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-05-31 15:35:16 -0300
committerEuAndreh <eu@euandre.org>2024-05-31 15:35:16 -0300
commit88f5df59c94fa48c832118e81e6ddf2759cb0231 (patch)
treeeb7aba63f2a6aa1e84a91ae3811a0275d19f2399 /src/set.c
parentUse freeit() everywhere (diff)
downloadpindaiba-88f5df59c94fa48c832118e81e6ddf2759cb0231.tar.gz
pindaiba-88f5df59c94fa48c832118e81e6ddf2759cb0231.tar.xz
Add initial private functions for src/set.c and src/tree.c
Diffstat (limited to 'src/set.c')
-rw-r--r--src/set.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/set.c b/src/set.c
new file mode 100644
index 0000000..3c03231
--- /dev/null
+++ b/src/set.c
@@ -0,0 +1,53 @@
+#include "config.h"
+
+#include <assert.h>
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "logerr.h"
+#include "util.h"
+
+#include "set.h"
+
+
+
+struct Set {
+ size_t count;
+};
+
+
+
+int
+set_new(const struct Set **const out) {
+ int rc = -1;
+
+ const struct Set *ret = NULL;
+
+ ret = malloc(sizeof(*ret));
+ if (ret == NULL) {
+ logerr("malloc(): %s", strerror(errno));
+ goto out;
+ }
+
+ memcpy((void *)ret, &(struct Set) {
+ .count = 0U,
+ }, sizeof(*ret));
+ *out = ret;
+ rc = 0;
+out:
+ if (rc) {
+ if (ret != NULL) {
+ freeit((void *)&ret);
+ }
+ }
+ return rc;
+}
+
+void
+set_free(const struct Set **const s) {
+ assert((*s) != NULL);
+ free((void *)*s);
+}