ReactOS  0.4.15-dev-1206-g731eddf
rosmem.c
Go to the documentation of this file.
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 *
12 {
14 }
15 
16 void *
18 {
19  void *mem = malloc(count * size);
20 
21  if (!mem) return NULL;
22 
24 
25  return mem;
26 }
27 
28 void
29 free(void *mem)
30 {
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 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
void * malloc(mem_size_t size)
Definition: rosmem.c:11
GLuint GLuint GLsizei count
Definition: gl.h:1545
void free(void *mem)
Definition: rosmem.c:29
void * realloc(void *mem, size_t size)
Definition: rosmem.c:36
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
u16_t mem_size_t
Definition: mem.h:76
void * calloc(mem_size_t count, mem_size_t size)
Definition: rosmem.c:17
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define LWIP_TAG
Definition: rosmem.c:7
Definition: mem.c:156
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099