malloc16.h
1/***************************************************************************
2 *
3 * Copyright (C) 2008 by Willem van Straten
4 * Licensed under the Academic Free License version 2.1
5 *
6 ***************************************************************************/
7
8// psrchive/Util/genutil/malloc16.h
9
10#ifndef __Utils_genutil_malloc16_h
11#define __Utils_genutil_malloc16_h
12
13#include <sys/types.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/* return an newly allocated array with base pointer % 16 == 0 */
20void* malloc16 (size_t n);
21
22/* free an array allocated with malloc16 */
23void free16 (void* p);
24
25#ifdef __cplusplus
26}
27
28template<typename T>
29class Array16
30{
31public:
32
33 Array16 (size_t n) { ptr = (T*) malloc16 (sizeof(T) * n); }
34 ~Array16 () { if (ptr) free16 (ptr); }
35 operator T* () { return ptr; }
36 T* get() { return ptr; }
37 bool operator ! () { return ptr == 0; }
38
39protected:
40 T* ptr;
41};
42
43#endif
44
45#endif
46

Generated using doxygen 1.14.0