Forgot to commit changelog with my last set of changes
[crack-attack.git] / enet / callbacks.c
blob7f960af3f409e12bdd228542930e3243b05812ea
1 /**
2 @file callbacks.c
3 @brief ENet callback functions
4 */
5 #define ENET_BUILDING_LIB 1
6 #include "enet/enet.h"
8 static ENetCallbacks callbacks = { malloc, free, rand };
10 int
11 enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits)
13 if (version != ENET_VERSION)
14 return -1;
16 if (inits -> malloc != NULL || inits -> free != NULL)
18 if (inits -> malloc == NULL || inits -> free == NULL)
19 return -1;
21 callbacks.malloc = inits -> malloc;
22 callbacks.free = inits -> free;
25 if (inits -> rand != NULL)
26 callbacks.rand = inits -> rand;
28 return enet_initialize ();
31 void *
32 enet_malloc (size_t size)
34 void * memory = callbacks.malloc (size);
36 if (memory == NULL)
37 abort ();
39 return memory;
42 void
43 enet_free (void * memory)
45 callbacks.free (memory);
48 int
49 enet_rand (void)
51 return callbacks.rand ();