Skip to contentSkip to conversation

add objpool to libsepol

PATCH In review Karl MacMillan 2 participants 6 messages Apr 19, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add objpool to libsepol

Add a reference counted object pool data structure to libsepol. Object pools allow the storage of reference counted pools of objects. This allows, for example, for many data structures to reference a single copy of an object (e.g., a string).

libsepol/include/sepol/objpool.h new file +139 -0
diff -r 7e5ed01cd8ad libsepol/include/sepol/objpool.h
@@ -0,0 +1,139 @@
+/* Author : Karl MacMillan <[email protected]> */
+
+#ifndef __objpool_h__
+#define __objpool_h__
+
+#include <sepol/handle.h>
+
+/**
+ * \defgroup libsepol_objpool sepol_objpool: reference counted object pooling
+ * Object pools allow the storage of reference counted pools of objects. This
+ * allows, for example, for many data structures to reference a single
+ * copy of an object (e.g., a string).
+ *
+ * Each object pool stores a single type of object. Hashing, comparison,
+ * and freeing functions must be provided by the user for the object
+ * to be stored. The objects are treated as generic void pointers by
+ * the object pool, and are not manipulated or interpreted in any way.
+ *
+ * The object pool manages the memory for objects. For example, consider
+ * the following example (error handling omitted for brevity):
+ *
+ * \code
+ * struct sepol_objpool *p;
+ * char *a = strdup("foo");
+ * char *b = strdup("foo");
+ * char *c = strdup("bar");
+ *
+ * // creation of object pool ommitted
+ * sepol_object_add(p, &a);
+ * sepol_object_add(p, &b);
+ * assert(a == b);
+ * // a and b now point to a single copy for the string "foo".
+ * // The copy originally pointed to by b has been destroyed.
+ * sepol_object_add(p, &c);
+ * sepol_object_del(p, c);
+ * // The object pool has destroyed its copy of the string "bar"
+ * // because the reference count became 0. The pointer c is no
+ * // longer valid.
+ * sepol_object_del(p, "foo");
+ * sepol_object_del(p, a);
+ * // deletion can use objects that compare as equal in addition
+ * // to pointers. The object pool is now empty.
+ * \endcode
+ */
+
+/* FIXME: These are the same as the hashing and key compare functions
+ * in policydb/hashtab.h - when hashtab.h is properly encapsulated and
+ * exported these should be merged.
+ */
+typedef unsigned int (*sepol_objpool_hash_t)(void *h, const void *key);
+typedef int (*sepol_objpool_cmp_t)(void *h, const void *key1, const void *key2);
+typedef void (*sepol_objpool_free_t)(void *obj);
+
+/**
+ * \ingroup libsepol_objpool
+ * \struct sepol_objpool
+ * The object pool data structure.
+ */
+struct sepol_objpool;
+
+/**
+ * \ingroup libsepol_objpool
+ * Create an object pool.
+ *
+ * Create an object pool with the appropriate functions for hashing,
+ * comparing, and freeing of the object type to be stored in the pool.
+ *
+ * @param h sepol handle (may be NULL)
+ * @param s pointer that will be set to the newly created object pool.
+ * @param hash pointer to a function to hash objects that will be managed
+ *  by the object pool. See sepol_symhash defined policydb/symtab.h for
+ *  an example hashing function.
+ * @param cmp pointer to a function to compare object that will be managed
+ *  by the object pool.
+ * @param obj_free pointer to a function to free the memory for objects
+ *  managed by the object pool.
+ * @param size size of the underlying hash table used to hold the objects.
+ *
+ * \retval SEPOL_OK success
+ * \retval SEPOL_ENOMEM out of memory
+ */
+extern int sepol_objpool_create(struct sepol_handle * h, struct sepol_objpool **s,
+				sepol_objpool_hash_t hash, sepol_objpool_cmp_t cmp,
+				sepol_objpool_free_t obj_free, unsigned int size);
+
+/**
+ * \ingroup libsepol_objpool
+ * Destroy an object pool. All of the memory associated with the object
+ * pool and all of the objects that it is managing is freed.
+ *
+ * @param h sepol handle (may be NULL)
+ * @param s object pool to destroy
+ *
+ * \retval SEPOL_OK success
+ * \retval SEPOL_ENOMEM out of memory
+ */
+extern int sepol_objpool_free(struct sepol_handle *h, struct sepol_objpool *s);
+
+/**
+ * \ingroup libsepol_objpool
+ * Add an object to the object pool. The pointer passed in
+ * will be set to point to the object pool copy of the object
+ * (the pointer may or may not change depending upon whether
+ * the object pool already contains a copy of the object). If
+ * the object pool already contains a copy of the passed in object
+ * the passed in copy will be freed and the reference count of
+ * the existing object will be incremented.
+ *
+ * @param h sepol handle (may be NULL)
+ * @param s object pool to which to add the object
+ * @param obj object to be added
+ *
+ * \retval SEPOL_OK success
+ * \retval SEPOL_ENOMEM out of memory
+ */
+extern int sepol_objpool_add(struct sepol_handle *h, struct sepol_objpool *s, void **obj);
+
+/**
+ * \ingroup libsepol_objpool
+ *
+ * Delete an object from the object pool. If other references to the
+ * object remain (from calls to sepol_objpool_add) the object will not
+ * be destroyed. However, the caller should *never* depend upon the
+ * object persisting beyond a call sepol_objpool_del. The object
+ * passed in does is not required to be a pointer returned by
+ * sepol_objpool_add; however, it is required to compare as equal to
+ * an existing object.
+ *
+ * @param h sepol handle (may be NULL)
+ * @param s object pool from which to delete object
+ * @param obj object to delete
+ *
+ * \retval SEPOL_OK success
+ * \retval SEPOL_ENOENT object does not exist in pool
+ * \retval SEPOL_ENOMEM out of memory
+ */
+extern int sepol_objpool_del(struct sepol_handle *h, struct sepol_objpool *s, void *obj);
+
+#endif
libsepol/src/objpool.c new file +135 -0

135 lines not on this page · raw message

libsepol/tests/libsepol-tests.c +2 -0
diff -r 7e5ed01cd8ad libsepol/tests/libsepol-tests.c
@@ -24,6 +24,7 @@
 #include "test-deps.h"
 #include "test-list.h"
 #include "test-hashtab.h"
+#include "test-objpool.h"
 
 #include <CUnit/Basic.h>
 #include <CUnit/Console.h>
@@ -65,6 +66,7 @@ static int do_tests(int interactive, int
 	DECLARE_SUITE(deps);
 	DECLARE_SUITE(list);
 	DECLARE_SUITE(hashtab);
+	DECLARE_SUITE(objpool);
 
 	if (verbose)
 		CU_basic_set_mode(CU_BRM_VERBOSE);
libsepol/tests/test-objpool.c new file +117 -0

117 lines not on this page · raw message

libsepol/tests/test-objpool.h new file +12 -0
diff -r 7e5ed01cd8ad libsepol/tests/test-objpool.h
@@ -0,0 +1,12 @@
+/* Author : Karl MacMillan <[email protected]> */
+
+#ifndef __test_objpool_h__
+#define __test_objpool_h__
+
+#include <CUnit/Basic.h>
+
+int objpool_test_init(void);
+int objpool_test_cleanup(void);
+int objpool_add_tests(CU_pSuite suite);
+
+#endif

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#1 lore raw
Quoted 4 lines · Karl MacMillan

Add a reference counted object pool data structure to libsepol. Object pools allow the storage of reference counted pools of objects. This allows, for example, for many data structures to reference a single copy of an object (e.g., a string).

As a general observation this makes me want to cry for the silent death
of a common C string ADT. But everyone has to reinvent their own so...

Quoted 1 line

+int sepol_objpool_free(struct sepol_handle *h, struct sepol_objpool *s)

If this is going to be used a lot having only a single "destroy"
function that also silently unref's everything it's managing seems "bad".
One obvious problem this causes is that if sepol_objpool_free() returns
in error you don't know if it's from the iter create (everything fine, try again) or from the sepol_iter_free (everything free'd already ... you are totally screwed). Luckily sepol_iter_free can't ever do that.

Quoted 1 line

+int sepol_objpool_add(struct sepol_handle *h, struct sepol_objpool *s, void **obj)

One minor point here is that while (char *) can change to (void *),
(char **) cannot change to (void **), legally. see:

http://c-faq.com/ptrs/genericpp.html

...having a real string ADT would do the right thing (cough) ... ok I'll shutup now.

libsepol/src/objpool.c line 94

Quoted 11 lines
libsepol/src/objpool.c new file +11 -0
+{
+	int ret;
+	hashtab_ptr_t cur;
+	unsigned int *refcount;
+
+	refcount = malloc(sizeof(unsigned int));
+	if (refcount == NULL)
+		return SEPOL_ENOMEM;
+	*refcount = 1;
+
+	ret = hashtab_insert2(s->objs, *obj, refcount, &cur);

hashtab_insert2() seems like a hack based on the fact you can't use the
result of hashtab_search().

libsepol/src/objpool.c line 95

Quoted 1 line
libsepol/src/objpool.c new file +1 -0
+	if (ret == SEPOL_OK) {

This doesn't copy "*obj" and so assumes s->obj_free is used to free the
input.

libsepol/src/objpool.c line 103

Quoted 8 lines
libsepol/src/objpool.c new file +8 -0
+		return 0;
+	} else if (ret == SEPOL_EEXIST) {
+		free(refcount);
+		s->obj_free(*obj);
+		*obj = cur->key;
+		refcount = cur->datum;
+		*refcount += 1;
+		return 0;

This also assumes s->obj_free is the correct thing to use for the
input.

Quoted 5 lines
libsepol/src/objpool.c new file +5 -0
+	} else {
+		free(refcount);
+		return ret;
+	}
+}

[...]

Quoted 6 lines
libsepol/src/objpool.c new file +6 -0
+int sepol_objpool_del(struct sepol_handle *h, struct sepol_objpool *s, void *obj)
+{
+	int ret;
+	unsigned int *refcount;
+	
+	refcount = hashtab_search(s->objs, obj);

libsepol/src/objpool.c line 133

Quoted 10 lines
libsepol/src/objpool.c new file +10 -0
+	if (refcount == NULL)
+		return SEPOL_ENOENT;
+	
+	(*refcount)--;
+	if (*refcount == 0) {
+		ret = hashtab_remove(s->objs, obj,
+				     sepol_objpool_hashtab_free, s);
+		if (ret != SEPOL_OK)
+			return ret;
+	}

The only thing hashtab_remove() returns, apart from _OK, is _ENOENT ...
which would mean it could be unref'd or not ... if hashtab_remove() could return it in this codepath.
Also if you fixed the hashtab_search followed by hashtab_insert
problem, then this codepath could also benefit in the same way (or maybe just have hashtab_remove2 ;).

Signature · 1 line
James Antill <[email protected]>
#2 lore raw
Quoted 9 lines · James Antill
Quoted 4 lines · Karl MacMillan

Add a reference counted object pool data structure to libsepol. Object pools allow the storage of reference counted pools of objects. This allows, for example, for many data structures to reference a single copy of an object (e.g., a string).

As a general observation this makes me want to cry for the silent death
of a common C string ADT. But everyone has to reinvent their own so...

To be fair - this is more general than strings. Of course, if C string handling were reasonable then I might not have done this.

Quoted 5 lines
Quoted 1 line

+int sepol_objpool_free(struct sepol_handle *h, struct sepol_objpool *s)

If this is going to be used a lot having only a single "destroy"
function that also silently unref's everything it's managing seems "bad".

I'm only intending to use this in the new policyrep where the lifetime of the object pool will be tied to the lifetime of the policy tree. I could add a destroy function that just destroys the pool though. I'd likely need to add a way to iterate over all of the objects in the pool to make this generally useful.

Quoted 5 lines

One obvious problem this causes is that if sepol_objpool_free() returns
in error you don't know if it's from the iter create (everything fine, try again) or from the sepol_iter_free (everything free'd already ... you are totally screwed). Luckily sepol_iter_free can't ever do that.

I know - that is irritating me. I can look at some internal iterators headers for stack allocation, but I don't think it will be pretty. I can also add error codes that indicate retry. Any other suggestions?

Quoted 7 lines
Quoted 1 line

+int sepol_objpool_add(struct sepol_handle *h, struct sepol_objpool *s, void **obj)

One minor point here is that while (char *) can change to (void *),
(char **) cannot change to (void **), legally. see:

http://c-faq.com/ptrs/genericpp.html

Well that sucks. I'll change the function prototype. I'll need to do the same thing for the iterators.

Quoted 18 lines

...having a real string ADT would do the right thing (cough) ... ok I'll shutup now.

libsepol/src/objpool.c line 94

Quoted 11 lines
libsepol/src/objpool.c new file +11 -0
+{
+	int ret;
+	hashtab_ptr_t cur;
+	unsigned int *refcount;
+
+	refcount = malloc(sizeof(unsigned int));
+	if (refcount == NULL)
+		return SEPOL_ENOMEM;
+	*refcount = 1;
+
+	ret = hashtab_insert2(s->objs, *obj, refcount, &cur);

hashtab_insert2() seems like a hack based on the fact you can't use the
result of hashtab_search().

Yep.

Quoted 5 lines

libsepol/src/objpool.c line 95

Quoted 1 line
libsepol/src/objpool.c new file +1 -0
+	if (ret == SEPOL_OK) {

This doesn't copy "*obj" and so assumes s->obj_free is used to free the
input.

Yes.

Quoted 12 lines

libsepol/src/objpool.c line 103

Quoted 8 lines
libsepol/src/objpool.c new file +8 -0
+		return 0;
+	} else if (ret == SEPOL_EEXIST) {
+		free(refcount);
+		s->obj_free(*obj);
+		*obj = cur->key;
+		refcount = cur->datum;
+		*refcount += 1;
+		return 0;

This also assumes s->obj_free is the correct thing to use for the
input.

Yes - that is intentional to avoid additional copying. Are you pointing out a problem, or just suggesting the constraint needs documentation?

Quoted 18 lines
Quoted 5 lines
libsepol/src/objpool.c new file +5 -0
+	} else {
+		free(refcount);
+		return ret;
+	}
+}

[...]

Quoted 12 lines
libsepol/src/objpool.c new file +12 -0
+int sepol_objpool_del(struct sepol_handle *h, struct sepol_objpool *s, void *obj)
+{
+	int ret;
+	unsigned int *refcount;
+	
+	refcount = hashtab_search(s->objs, obj);
+	if (refcount == NULL)
+		return SEPOL_ENOENT;
+	
+	(*refcount)--;
+	if (*refcount == 0) {
+		ret = hashtab_remove(s->objs, obj,
Quoted 8 lines

libsepol/src/objpool.c line 133

Quoted 4 lines
libsepol/src/objpool.c new file +4 -0
+				     sepol_objpool_hashtab_free, s);
+		if (ret != SEPOL_OK)
+			return ret;
+	}

The only thing hashtab_remove() returns, apart from _OK, is _ENOENT ...
which would mean it could be unref'd or not ... if hashtab_remove() could return it in this codepath.

Not certain what you mean. Generally, these APIs aren't thread safe so I assume that the remove will succeed here. The error checking is for future changes in the hashtab implementation.

Quoted 4 lines

Also if you fixed the hashtab_search followed by hashtab_insert
problem, then this codepath could also benefit in the same way (or maybe just have hashtab_remove2 ;).

Sure. The hashtab API needs some cleanup and encapsulation, but I decided to leave it for another day.

I'll submit a new patch with the needed changes.

Karl

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#3 lore raw
Quoted 8 lines · Karl MacMillan
Quoted 6 lines · James Antill
Quoted 1 line · Karl MacMillan

+int sepol_objpool_free(struct sepol_handle *h, struct sepol_objpool *s)

If this is going to be used a lot having only a single "destroy"
function that also silently unref's everything it's managing seems "bad".

Quoted 5 lines

I'm only intending to use this in the new policyrep where the lifetime of the object pool will be tied to the lifetime of the policy tree. I could add a destroy function that just destroys the pool though. I'd likely need to add a way to iterate over all of the objects in the pool to make this generally useful.

So, sepol_objpool_del() will never be called? If so it seems better to
have it work like an APR memory pool or obstack etc. where you allocate a bunch of small objects but only remove the entire thing once.

Quoted 19 lines
Quoted 4 lines

libsepol/src/objpool.c line 95

Quoted 1 line
libsepol/src/objpool.c new file +1 -0
+	if (ret == SEPOL_OK) {

This doesn't copy "*obj" and so assumes s->obj_free is used to free the
input.

Yes.

Quoted 11 lines

libsepol/src/objpool.c line 103

Quoted 8 lines
libsepol/src/objpool.c new file +8 -0
+		return 0;
+	} else if (ret == SEPOL_EEXIST) {
+		free(refcount);
+		s->obj_free(*obj);
+		*obj = cur->key;
+		refcount = cur->datum;
+		*refcount += 1;
+		return 0;

This also assumes s->obj_free is the correct thing to use for the
input.

Quoted 2 lines

Yes - that is intentional to avoid additional copying. Are you pointing out a problem, or just suggesting the constraint needs documentation?

I guess I just wonder why have the s->obj_free member at all, esp.
given the examples used with strdup() ... I kind of assumed you expected input from strdup(), given the examples, and so was confused about the non-useage of free().
It also just seems wrong to have the member free function used for
input ... but if you have a use case feel free to ignore me :).

Quoted 27 lines
Quoted 18 lines
Quoted 5 lines
libsepol/src/objpool.c new file +5 -0
+	} else {
+		free(refcount);
+		return ret;
+	}
+}

[...]

Quoted 12 lines
libsepol/src/objpool.c new file +12 -0
+int sepol_objpool_del(struct sepol_handle *h, struct sepol_objpool *s, void *obj)
+{
+	int ret;
+	unsigned int *refcount;
+	
+	refcount = hashtab_search(s->objs, obj);
+	if (refcount == NULL)
+		return SEPOL_ENOENT;
+	
+	(*refcount)--;
+	if (*refcount == 0) {
+		ret = hashtab_remove(s->objs, obj,
Quoted 8 lines

libsepol/src/objpool.c line 133

Quoted 4 lines
libsepol/src/objpool.c new file +4 -0
+				     sepol_objpool_hashtab_free, s);
+		if (ret != SEPOL_OK)
+			return ret;
+	}

The only thing hashtab_remove() returns, apart from _OK, is _ENOENT ...
which would mean it could be unref'd or not ... if hashtab_remove() could return it in this codepath.

Quoted 3 lines

Not certain what you mean. Generally, these APIs aren't thread safe so I assume that the remove will succeed here. The error checking is for future changes in the hashtab implementation.

Sorry, bad English on my part. My point was that I don't see how
hashtab_remove() could ever return in error here (as you've already made sure it is there) ... and even if it ever did return in error at some future point, you are leaking a reference count (*refcount == 0, but there is still one reference in the hashtab).

Signature · 1 line
James Antill <[email protected]>
#4 lore raw
Quoted 9 lines · James Antill
Quoted 8 lines · Karl MacMillan
Quoted 6 lines · James Antill
Quoted 1 line · Karl MacMillan

+int sepol_objpool_free(struct sepol_handle *h, struct sepol_objpool *s)

If this is going to be used a lot having only a single "destroy"
function that also silently unref's everything it's managing seems "bad".

Quoted 7 lines
Quoted 5 lines

I'm only intending to use this in the new policyrep where the lifetime of the object pool will be tied to the lifetime of the policy tree. I could add a destroy function that just destroys the pool though. I'd likely need to add a way to iterate over all of the objects in the pool to make this generally useful.

So, sepol_objpool_del() will never be called?

It is - as you make changes to the policy tree strings can be removed as objects are. Actually, as you delete the policy tree the object pool should empty. It is probably an error if there is anything left in the pool when the root node in the tree is destroyed. Hmm - maybe I should change this to add / remove and let the caller allocated and deallocate all of the objects (see below for why that is inconvenient though).

Quoted 4 lines

If so it seems better to
have it work like an APR memory pool or obstack etc. where you allocate a bunch of small objects but only remove the entire thing once.

No - that is not quite the intended use.

Quoted 19 lines
Quoted 19 lines
Quoted 4 lines

libsepol/src/objpool.c line 95

Quoted 1 line
libsepol/src/objpool.c new file +1 -0
+	if (ret == SEPOL_OK) {

This doesn't copy "*obj" and so assumes s->obj_free is used to free the
input.

Yes.

Quoted 11 lines

libsepol/src/objpool.c line 103

Quoted 8 lines
libsepol/src/objpool.c new file +8 -0
+		return 0;
+	} else if (ret == SEPOL_EEXIST) {
+		free(refcount);
+		s->obj_free(*obj);
+		*obj = cur->key;
+		refcount = cur->datum;
+		*refcount += 1;
+		return 0;

This also assumes s->obj_free is the correct thing to use for the
input.

Quoted 7 lines
Quoted 2 lines

Yes - that is intentional to avoid additional copying. Are you pointing out a problem, or just suggesting the constraint needs documentation?

I guess I just wonder why have the s->obj_free member at all, esp.
given the examples used with strdup() ... I kind of assumed you expected input from strdup(), given the examples, and so was confused about the non-useage of free().

Ahh - but the objects can be arbitrary, so they might be structs that need something more than free.

Quoted 3 lines

It also just seems wrong to have the member free function used for
input ... but if you have a use case feel free to ignore me :).

Well, the model I was thinking was that the caller was giving ownership of the object to the pool. The advantage is that the caller simply calls add and doesn't have to check return codes to see if their copy of the object should be freed. Otherwise the caller would conditionally free the object depending on whether another copy already existed. Object deletion would have the same problem.

Quoted 27 lines
Quoted 27 lines
Quoted 26 lines
Quoted 5 lines
libsepol/src/objpool.c new file +5 -0
+	} else {
+		free(refcount);
+		return ret;
+	}
+}

[...]

Quoted 6 lines
libsepol/src/objpool.c new file +6 -0
+int sepol_objpool_del(struct sepol_handle *h, struct sepol_objpool *s, void *obj)
+{
+	int ret;
+	unsigned int *refcount;
+	
+	refcount = hashtab_search(s->objs, obj);

libsepol/src/objpool.c line 133

Quoted 10 lines
libsepol/src/objpool.c new file +10 -0
+	if (refcount == NULL)
+		return SEPOL_ENOENT;
+	
+	(*refcount)--;
+	if (*refcount == 0) {
+		ret = hashtab_remove(s->objs, obj,
+				     sepol_objpool_hashtab_free, s);
+		if (ret != SEPOL_OK)
+			return ret;
+	}

The only thing hashtab_remove() returns, apart from _OK, is _ENOENT ...
which would mean it could be unref'd or not ... if hashtab_remove() could return it in this codepath.

Quoted 7 lines
Quoted 3 lines

Not certain what you mean. Generally, these APIs aren't thread safe so I assume that the remove will succeed here. The error checking is for future changes in the hashtab implementation.

Sorry, bad English on my part. My point was that I don't see how
hashtab_remove() could ever return in error here (as you've already made sure it is there)

It shouldn't.

Quoted 4 lines

... and even if it ever did return in error at some
future point, you are leaking a reference count (*refcount == 0, but there is still one reference in the hashtab).

If it did return an error you don't know whether you are leaking or not
- likely things are just screwed, which is why I punt and return the error for the caller to figure out how to handle :) Eventually the hashtab API can be fixed so that this is not an issue.

Karl

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.

#5 lore raw
Quoted 10 lines · Karl MacMillan
Quoted 4 lines · James Antill

I guess I just wonder why have the s->obj_free member at all, esp.
given the examples used with strdup() ... I kind of assumed you expected input from strdup(), given the examples, and so was confused about the non-useage of free().

Ahh - but the objects can be arbitrary, so they might be structs that need something more than free.

Quoted 7 lines
Quoted 2 lines

It also just seems wrong to have the member free function used for
input ... but if you have a use case feel free to ignore me :).

Well, the model I was thinking was that the caller was giving ownership of the object to the pool. The advantage is that the caller simply calls add and doesn't have to check return codes to see if their copy of the object should be freed.

Well it needs to check for errors, and do something different then.

Quoted 3 lines

Otherwise the caller would conditionally free
the object depending on whether another copy already existed. Object deletion would have the same problem.

Yeh, I understand ... it feels kind of wrong to be mixing layers. Ie.
conceptually you seem to have:

struct higher_layer {
void *(*make)(void); /* allocate */

  struct lower_layer {
    void (*free)(void *); /* deallocate */

} lower;
};

...which I don't see often, and so assumed was wrong ... but it works, you obviously meant to do it, and I can't see a quick way to split the layers without downsides.

Signature · 1 line
James Antill <[email protected]>