summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/til_setup.c26
-rw-r--r--src/til_setup.h2
3 files changed, 29 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f3d400..20ef90f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
SUBDIRS = libs modules
noinst_LTLIBRARIES = libtil.la
-libtil_la_SOURCES = til_args.c til_args.h til_fb.c til_fb.h til_knobs.h til.c til.h til_settings.h til_settings.c til_setup.h til_threads.c til_threads.h til_util.c til_util.h
+libtil_la_SOURCES = til_args.c til_args.h til_fb.c til_fb.h til_knobs.h til.c til.h til_settings.h til_settings.c til_setup.c til_setup.h til_threads.c til_threads.h til_util.c til_util.h
libtil_la_CPPFLAGS = -I@top_srcdir@/src
libtil_la_LIBADD = modules/blinds/libblinds.la modules/checkers/libcheckers.la modules/compose/libcompose.la modules/drizzle/libdrizzle.la modules/flui2d/libflui2d.la modules/julia/libjulia.la modules/meta2d/libmeta2d.la modules/montage/libmontage.la modules/pixbounce/libpixbounce.la modules/plasma/libplasma.la modules/plato/libplato.la modules/ray/libray.la modules/roto/libroto.la modules/rtv/librtv.la modules/snow/libsnow.la modules/sparkler/libsparkler.la modules/spiro/libspiro.la modules/stars/libstars.la modules/submit/libsubmit.la modules/swab/libswab.la modules/swarm/libswarm.la libs/grid/libgrid.la libs/puddle/libpuddle.la libs/ray/libray.la libs/sig/libsig.la libs/txt/libtxt.la libs/ascii/libascii.la libs/din/libdin.la
diff --git a/src/til_setup.c b/src/til_setup.c
new file mode 100644
index 0000000..c5fd451
--- /dev/null
+++ b/src/til_setup.c
@@ -0,0 +1,26 @@
+#include <assert.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include "til_setup.h"
+
+
+/* Allocate and initialize a new til_setup_t of size bytes.
+ * free_func is assigned to til_setup_t.free, and will be used for freeing the
+ * instance returned when destroyed.
+ */
+void * til_setup_new(size_t size, void (*free_func)(til_setup_t *setup))
+{
+ til_setup_t *setup;
+
+ assert(size >= sizeof(til_setup_t));
+ assert(free_func);
+
+ setup = calloc(1, size);
+ if (!setup)
+ return NULL;
+
+ setup->free = free_func;
+
+ return setup;
+}
diff --git a/src/til_setup.h b/src/til_setup.h
index 7984dd1..7f61213 100644
--- a/src/til_setup.h
+++ b/src/til_setup.h
@@ -7,4 +7,6 @@ struct til_setup_t {
void (*free)(til_setup_t *setup);
};
+void * til_setup_new(size_t size, void (*free_func)(til_setup_t *setup));
+
#endif
© All Rights Reserved