File: mem.h

package info (click to toggle)
mercury 0.9-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 18,488 kB
  • ctags: 9,800
  • sloc: objc: 146,680; ansic: 51,418; sh: 6,436; lisp: 1,567; cpp: 1,040; perl: 854; makefile: 450; asm: 232; awk: 203; exp: 32; fortran: 3; csh: 1
file content (39 lines) | stat: -rw-r--r-- 994 bytes parent folder | download
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
28
29
30
31
32
33
34
35
36
37
38
39
/*
** Copyright (C) 1997 The University of Melbourne.
** This file may only be copied under the terms of the GNU Library General
** Public License - see the file COPYING.LIB in the Mercury distribution.
**
** $Id: mem.h,v 1.7 1997/07/27 14:59:28 fjh Exp $
*/

/*
** This file provides memory allocation functions for use by the bytecode
** utilities.
*/

#ifndef MB_MEMALLOC_H
#define	MB_MEMALLOC_H

#include	<stdlib.h>	/* for size_t */

/*
** Do not use MB_malloc() or MB_realloc() directly, unless you want
** to allocate raw memory.  Normally you should use the macros
** MB_new(), MB_new_array(), and MB_resize_array() instead.
*/

void*
MB_malloc(size_t size);

void*
MB_realloc(void *mem, size_t size);

void
MB_free(void *mem);

#define MB_new(type)		((type *) MB_malloc(sizeof(type)))
#define MB_new_array(type, num)	((type *) MB_malloc((num) * sizeof(type)))
#define MB_resize_array(array, type, num) \
	((type *) MB_realloc((array), (num) * sizeof(type)))

#endif	/* MB_MEMALLOC_H */