debuggers.hg

view xen/include/xen/xmalloc.h @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children f875aaa791f0
line source
2 #ifndef __XMALLOC_H__
3 #define __XMALLOC_H__
5 /* Allocate space for typed object. */
6 #define xmalloc(_type) ((_type *)_xmalloc(sizeof(_type), __alignof__(_type)))
8 /* Allocate space for array of typed objects. */
9 #define xmalloc_array(_type, _num) ((_type *)_xmalloc_array(sizeof(_type), __alignof__(_type), _num))
11 /* Allocate untyped storage. */
12 #define xmalloc_bytes(_bytes) (_xmalloc(_bytes, SMP_CACHE_BYTES))
14 /* Free any of the above. */
15 extern void xfree(void *);
17 /* Underlying functions */
18 extern void *_xmalloc(size_t size, size_t align);
19 static inline void *_xmalloc_array(size_t size, size_t align, size_t num)
20 {
21 /* Check for overflow. */
22 if (size && num > UINT_MAX / size)
23 return NULL;
24 return _xmalloc(size * num, align);
25 }
27 #endif /* __XMALLOC_H__ */