source: azure_iot_hub/trunk/musl-1.1.18/src/malloc/malloc_usable_size.c@ 388

Last change on this file since 388 was 388, checked in by coas-nagasima, 5 years ago

Azure IoT Hub Device C SDK を使ったサンプルの追加

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-csrc
File size: 384 bytes
Line 
1#include <malloc.h>
2
3void *(*const __realloc_dep)(void *, size_t) = realloc;
4
5struct chunk {
6 size_t psize, csize;
7 struct chunk *next, *prev;
8};
9
10#define OVERHEAD (2*sizeof(size_t))
11#define CHUNK_SIZE(c) ((c)->csize & -2)
12#define MEM_TO_CHUNK(p) (struct chunk *)((char *)(p) - OVERHEAD)
13
14size_t malloc_usable_size(void *p)
15{
16 return p ? CHUNK_SIZE(MEM_TO_CHUNK(p)) - OVERHEAD : 0;
17}
Note: See TracBrowser for help on using the repository browser.