Remove unnecessary executable bits
[reactos.git] / sdk / lib / drivers / lwip / src / rosmem.c
1 #include "lwip/opt.h"
2
3 #include "lwip/def.h"
4 #include "lwip/mem.h"
5
6 #ifndef LWIP_TAG
7 #define LWIP_TAG 'PIwl'
8 #endif
9
10 void *
11 malloc(mem_size_t size)
12 {
13 return ExAllocatePoolWithTag(NonPagedPool, size, LWIP_TAG);
14 }
15
16 void *
17 calloc(mem_size_t count, mem_size_t size)
18 {
19 void *mem = malloc(count * size);
20
21 if (!mem) return NULL;
22
23 RtlZeroMemory(mem, count * size);
24
25 return mem;
26 }
27
28 void
29 free(void *mem)
30 {
31 ExFreePoolWithTag(mem, LWIP_TAG);
32 }
33
34 /* This is only used to trim in lwIP */
35 void *
36 realloc(void *mem, size_t size)
37 {
38 void* new_mem;
39
40 /* realloc() with a NULL mem pointer acts like a call to malloc() */
41 if (mem == NULL) {
42 return malloc(size);
43 }
44
45 /* realloc() with a size 0 acts like a call to free() */
46 if (size == 0) {
47 free(mem);
48 return NULL;
49 }
50
51 /* Allocate the new buffer first */
52 new_mem = malloc(size);
53 if (new_mem == NULL) {
54 /* The old buffer is still intact */
55 return NULL;
56 }
57
58 /* Copy the data over */
59 RtlCopyMemory(new_mem, mem, size);
60
61 /* Deallocate the old buffer */
62 free(mem);
63
64 /* Return the newly allocated block */
65 return new_mem;
66 }