mirror of
https://github.com/lsalzman/enet.git
synced 2025-06-01 04:47:39 +00:00
1.3.0 import
This commit is contained in:
parent
2d985dba91
commit
572636062e
14 changed files with 300 additions and 131 deletions
21
callbacks.c
21
callbacks.c
|
@ -5,11 +5,14 @@
|
|||
#define ENET_BUILDING_LIB 1
|
||||
#include "enet/enet.h"
|
||||
|
||||
static ENetCallbacks callbacks = { malloc, free, rand, abort };
|
||||
static ENetCallbacks callbacks = { malloc, free, abort };
|
||||
|
||||
int
|
||||
enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits)
|
||||
{
|
||||
if (version < ENET_VERSION_CREATE (1, 3, 0))
|
||||
return -1;
|
||||
|
||||
if (inits -> malloc != NULL || inits -> free != NULL)
|
||||
{
|
||||
if (inits -> malloc == NULL || inits -> free == NULL)
|
||||
|
@ -19,14 +22,8 @@ enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits
|
|||
callbacks.free = inits -> free;
|
||||
}
|
||||
|
||||
if (inits -> rand != NULL)
|
||||
callbacks.rand = inits -> rand;
|
||||
|
||||
if (version >= ENET_VERSION_CREATE (1, 2, 2))
|
||||
{
|
||||
if (inits -> no_memory != NULL)
|
||||
callbacks.no_memory = inits -> no_memory;
|
||||
}
|
||||
if (inits -> no_memory != NULL)
|
||||
callbacks.no_memory = inits -> no_memory;
|
||||
|
||||
return enet_initialize ();
|
||||
}
|
||||
|
@ -48,9 +45,3 @@ enet_free (void * memory)
|
|||
callbacks.free (memory);
|
||||
}
|
||||
|
||||
int
|
||||
enet_rand (void)
|
||||
{
|
||||
return callbacks.rand ();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue