aboutsummaryrefslogtreecommitdiffstats
path: root/libexec_destroy_pluming.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libexec_destroy_pluming.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libexec_destroy_pluming.c b/libexec_destroy_pluming.c
new file mode 100644
index 0000000..6aae3c7
--- /dev/null
+++ b/libexec_destroy_pluming.c
@@ -0,0 +1,31 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+#ifndef TEST
+
+
+void
+libexec_destroy_pluming(struct libexec_pluming *pluming)
+{
+ if (!pluming)
+ return;
+
+ if (pluming->type == LIBEXEC_PLUMING_OPENAT ||
+ pluming->type == LIBEXEC_PLUMING_OPENAT2) {
+ free(pluming->target.file);
+ pluming->target.file = NULL;
+
+ } else if (pluming->type == LIBEXEC_PLUMING_DOCUMENT) {
+ free(pluming->target.text);
+ pluming->target.text = NULL;
+
+ } else if (pluming->type == LIBEXEC_PLUMING_PIPE) {
+ if (pluming->target.fd >= 0)
+ close(pluming->target.fd);
+ pluming->target.fd = -1;
+ }
+}
+
+
+#else
+LIBEXEC_CONST__ int main(void) {return 0;} /* TODO test */
+#endif