ReactOS 0.4.16-dev-197-g92996da
memory.c
Go to the documentation of this file.
1#include <lwip/mem.h>
2
3#ifndef LWIP_TAG
4 #define LWIP_TAG 'PIwl'
5#endif
6
7void *
9{
11}
12
13void *
15{
16 void *mem = malloc(count * size);
17
18 if (!mem) return NULL;
19
21
22 return mem;
23}
24
25void
26free(void *mem)
27{
29}
30
31/* This is only used to trim in lwIP */
32void *
33realloc(void *mem, size_t size)
34{
35 void* new_mem;
36
37 /* realloc() with a NULL mem pointer acts like a call to malloc() */
38 if (mem == NULL) {
39 return malloc(size);
40 }
41
42 /* realloc() with a size 0 acts like a call to free() */
43 if (size == 0) {
44 free(mem);
45 return NULL;
46 }
47
48 /* Allocate the new buffer first */
49 new_mem = malloc(size);
50 if (new_mem == NULL) {
51 /* The old buffer is still intact */
52 return NULL;
53 }
54
55 /* Copy the data over */
56 RtlCopyMemory(new_mem, mem, size);
57
58 /* Deallocate the old buffer */
59 free(mem);
60
61 /* Return the newly allocated block */
62 return new_mem;
63}
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define LWIP_TAG
Definition: memory.c:4
u16_t mem_size_t
Definition: mem.h:76
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define calloc
Definition: rosglue.h:14
Definition: mem.c:156
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262