summaryrefslogtreecommitdiff
path: root/tests/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/util.c')
-rw-r--r--tests/util.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/util.c b/tests/util.c
index f4e3d0c..ad43012 100644
--- a/tests/util.c
+++ b/tests/util.c
@@ -62,6 +62,38 @@ out:
return rc;
}
+static int
+test_freeit(void) {
+ int rc = -1;
+
+ test_start("freeit()");
+
+ const char *ptr = NULL;
+
+ {
+ testing("ptr is NULL afterwards");
+
+ ptr = malloc(1234U);
+ if (ptr == NULL) {
+ logerr("malloc(): %s\n", strerror(errno));
+ goto out;
+ }
+
+ assert(ptr != NULL);
+ freeit((void *)&ptr);
+ assert(ptr == NULL);
+
+ test_ok();
+ }
+
+ rc = 0;
+out:
+ if (ptr != NULL) {
+ freeit((void *)&ptr);
+ }
+ return rc;
+}
+
int
main(void) {
@@ -72,6 +104,11 @@ main(void) {
goto out;
}
+ if (test_freeit()) {
+ logerr("test_freeit();\n");
+ goto out;
+ }
+
rc = 0;
out:
return !!rc;