~ubuntu-branches/debian/stretch/assaultcube-data/stretch

« back to all changes in this revision

Viewing changes to source/enet/callbacks.c

  • Committer: Bazaar Package Importer
  • Author(s): Gonéri Le Bouder, Ansgar Burchardt, Gonéri Le Bouder
  • Date: 2010-04-02 23:37:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100402233755-kf74fxwlu634o6vg
Tags: 1.0.4+repack1-1
[ Ansgar Burchardt ]
* debian/control: fix typo in short description

[ Gonéri Le Bouder ]
* Upgrade to 1.0.4
* bump standards-version to 3.8.4
* Add Depends: ${misc:Depends} just to avoid a lintian warning
* Add a debian/source/format file for the same reason

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/** 
 
2
 @file callbacks.c
 
3
 @brief ENet callback functions
 
4
*/
 
5
#define ENET_BUILDING_LIB 1
 
6
#include "enet/enet.h"
 
7
 
 
8
static ENetCallbacks callbacks = { malloc, free, rand };
 
9
 
 
10
int
 
11
enet_initialize_with_callbacks (ENetVersion version, const ENetCallbacks * inits)
 
12
{
 
13
   if (version != ENET_VERSION)
 
14
     return -1;
 
15
 
 
16
   if (inits -> malloc != NULL || inits -> free != NULL)
 
17
   {
 
18
      if (inits -> malloc == NULL || inits -> free == NULL)
 
19
        return -1;
 
20
 
 
21
      callbacks.malloc = inits -> malloc;
 
22
      callbacks.free = inits -> free;
 
23
   }
 
24
      
 
25
   if (inits -> rand != NULL)
 
26
     callbacks.rand = inits -> rand;
 
27
 
 
28
   return enet_initialize ();
 
29
}
 
30
           
 
31
void *
 
32
enet_malloc (size_t size)
 
33
{
 
34
   void * memory = callbacks.malloc (size);
 
35
 
 
36
   if (memory == NULL)
 
37
     abort ();
 
38
 
 
39
   return memory;
 
40
}
 
41
 
 
42
void
 
43
enet_free (void * memory)
 
44
{
 
45
   callbacks.free (memory);
 
46
}
 
47
 
 
48
int
 
49
enet_rand (void)
 
50
{
 
51
   return callbacks.rand ();
 
52
}
 
53