debuggers.hg

diff xen/include/xen/slab.h @ 3664:8472fafee3cf

bitkeeper revision 1.1159.212.74 (42015ef3sPQp8pjeJAck1wBtTAYL9g)

Interface to typed allocator is now just xmalloc/xmalloc_array/xfree.
_xmalloc/_xmalloc_array are dead (or, at least, non-API).
Signed-off-by: keir.fraser@cl.cam.ac.uk
author kaf24@scramble.cl.cam.ac.uk
date Wed Feb 02 23:14:59 2005 +0000 (2005-02-02)
parents 0ef6e8e6e85d
children 07d5c9548534
line diff
     1.1 --- a/xen/include/xen/slab.h	Wed Feb 02 22:31:42 2005 +0000
     1.2 +++ b/xen/include/xen/slab.h	Wed Feb 02 23:14:59 2005 +0000
     1.3 @@ -54,16 +54,10 @@ extern int xmem_cache_reap(void);
     1.4  extern void dump_slabinfo();
     1.5  
     1.6  /* Nicely typesafe for you. */
     1.7 -#define xmalloc(type) ((type *)_xmalloc(sizeof(type)))
     1.8 -#define xmalloc_array(type, num) ((type *)_xmalloc_array(sizeof(type), (num)))
     1.9 -
    1.10 -static inline void *_xmalloc_array(size_t size, size_t num)
    1.11 -{
    1.12 -	/* Check for overflow. */
    1.13 -	if (size && num > UINT_MAX / size)
    1.14 -		return NULL;
    1.15 -	return _xmalloc(size * num);
    1.16 -}
    1.17 +#define xmalloc(_type) ((typeof(_type) *)_xmalloc(sizeof(_type)))
    1.18 +#define xmalloc_array(_type, _num)                 \
    1.19 +((_type *)(((_num) > (UINT_MAX / sizeof(_type))) ? \
    1.20 +           NULL : _xmalloc((_num) * sizeof(_type))))
    1.21  #endif /* __ARCH_HAS_SLAB_ALLOCATOR */
    1.22  
    1.23  #endif /* __SLAB_H__ */