~rabbits/hiversaires

7aa8797f43a0ebaa0a084010bffc5a0ae0baa686 — Rezmason 2 years ago a5570c1
Added function wrapping, to simplify passing functions into other functions that accept void *data
2 files changed, 13 insertions(+), 0 deletions(-)

M src/util.c
M src/util.h
M src/util.c => src/util.c +8 -0
@@ 17,6 17,14 @@ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE.
*/

FuncWrapper *
wrapFunction(void (*f)())
{
	FuncWrapper *func = malloc(sizeof(FuncWrapper));
	func->f = f;
	return func;
}

char *
concat(const char *s1, const char *s2)
{

M src/util.h => src/util.h +5 -0
@@ 19,6 19,11 @@ WITH REGARD TO THIS SOFTWARE.
	included in C89.
*/

typedef struct {
	void (*f)();
} FuncWrapper;

FuncWrapper *wrapFunction(void (*f)());
char *concat(const char *s1, const char *s2);
char *duplicate(const char *s);
int isMatch(char *c, const char *candidates);