File: malloc.h

package info (click to toggle)
valgrind 1%3A3.10.0-4~bpo7%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 97,940 kB
  • sloc: ansic: 589,429; xml: 21,096; exp: 8,751; cpp: 7,366; asm: 6,526; perl: 5,656; sh: 5,334; makefile: 4,946; haskell: 195
file content (27 lines) | stat: -rw-r--r-- 572 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Replacement for malloc.h which factors out platform differences.

#include <stdlib.h>
#if defined(VGO_darwin)
#  include <malloc/malloc.h>
#else
#  include <malloc.h>
#endif

#include <assert.h>

// Allocates a 16-aligned block.  Asserts if the allocation fails.
__attribute__((unused))
static void* memalign16(size_t szB)
{
   void* x;
#if defined(VGO_darwin)
   // Darwin lacks memalign, but its malloc is always 16-aligned anyway.
   x = malloc(szB);
#else
   x = memalign(16, szB);
#endif
   assert(x);
   assert(0 == ((16-1) & (unsigned long)x));
   return x;
}