SCM Repository
Annotation of /examples/util/util.h
Parent Directory
|
Revision Log
Revision 1884 - (view) (download) (as text)
1 : | jhr | 1884 | /*! \file util.h |
2 : | * | ||
3 : | * \brief This file contains miscellaneous definitions used in the program. | ||
4 : | * | ||
5 : | * \author John Reppy | ||
6 : | */ | ||
7 : | |||
8 : | /* | ||
9 : | * COPYRIGHT (c) 2012 The Diderot Project (http://diderot-language.cs.uchicago.edu) | ||
10 : | * All rights reserved. | ||
11 : | */ | ||
12 : | |||
13 : | #ifndef _UTIL_H_ | ||
14 : | #define _UTIL_H_ | ||
15 : | |||
16 : | /* incude standard headers */ | ||
17 : | #include <stdlib.h> | ||
18 : | #include <stdint.h> | ||
19 : | #include <stdbool.h> | ||
20 : | #include <assert.h> | ||
21 : | |||
22 : | /* include useful teem headers */ | ||
23 : | #include "teem/air.h" | ||
24 : | #include "teem/nrrd.h" | ||
25 : | #include "teem/biff.h" | ||
26 : | |||
27 : | /*! \brief allocate heap memory checking for failure. | ||
28 : | * \param nbytes the amount of memory to allocate in bytes. | ||
29 : | * \returns the allocated object. | ||
30 : | */ | ||
31 : | extern void *CheckMalloc (size_t nbytes); | ||
32 : | |||
33 : | static inline void Free (void *p) { if (p != 0) free(p); } | ||
34 : | |||
35 : | #define NEW(ty) (ty *)CheckMalloc(sizeof(ty)) | ||
36 : | #define NEWVEC(ty, n) (ty *)CheckMalloc(sizeof(ty)*(n)) | ||
37 : | #define FREE(p) Free(p) | ||
38 : | |||
39 : | #endif /* !_UTIL_H_ */ |
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |