source: vis_dev/glu-2.3/src/calBdd/calMem.h @ 43

Last change on this file since 43 was 13, checked in by cecile, 13 years ago

library glu 2.3

File size: 5.1 KB
RevLine 
[13]1/**CHeaderFile*****************************************************************
2
3  FileName    [calMem.h]
4
5  PackageName [cal]
6
7  Synopsis    [Header file for memory management]
8
9  Description [ ]
10
11  SeeAlso     []
12
13  Author      [Rajeev K. Ranjan (rajeev@eecs.berkeley.edu). Originally written by David Long. ]
14
15  Copyright   [Copyright (c) 1994-1996 The Regents of the Univ. of California.
16  All rights reserved.
17
18  Permission is hereby granted, without written agreement and without license
19  or royalty fees, to use, copy, modify, and distribute this software and its
20  documentation for any purpose, provided that the above copyright notice and
21  the following two paragraphs appear in all copies of this software.
22
23  IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
24  DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
25  OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
26  CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28  THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
29  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
30  FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN
31  "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE
32  MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]
33
34  Revision    [$Id: calMem.h,v 1.3 2002/08/28 16:01:01 fabio Exp $]
35
36******************************************************************************/
37
38#ifndef _CAL_MEM
39#define _CAL_MEM
40
41#include <stdio.h>
42
43/*---------------------------------------------------------------------------*/
44/* Constant declarations                                                     */
45/*---------------------------------------------------------------------------*/
46/* CAL_ALLOC_ALIGNMENT is the alignment for all storage returned by the */
47/* storage allocation routines. */
48/* was 16 for __osf__ systems, 8 otherwise */
49
50#define CAL_ALLOC_ALIGNMENT sizeof(void *)
51
52
53
54/*---------------------------------------------------------------------------*/
55/* Type declarations                                                         */
56/*---------------------------------------------------------------------------*/
57typedef struct Cal_RecMgrStruct * Cal_RecMgr;
58typedef void *Cal_Pointer_t;
59typedef size_t Cal_Address_t;
60/*---------------------------------------------------------------------------*/
61/* Stucture declarations                                                     */
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64/* Variable declarations                                                     */
65/*---------------------------------------------------------------------------*/
66
67/*---------------------------------------------------------------------------*/
68/* Macro declarations                                                        */
69/*---------------------------------------------------------------------------*/
70#ifndef EXTERN
71#  ifdef __cplusplus
72#    define EXTERN      extern "C"
73#  else
74#    define EXTERN      extern
75#  endif
76#endif
77#define Cal_Nil(obj) ((obj *)0)
78#define USE_OS_MEMORY_MANAGEMENT
79#ifdef USE_OS_MEMORY_MANAGEMENT
80#define Cal_MemAlloc(type, num) ((type *) malloc(sizeof(type) * (num)))
81#define Cal_MemRealloc(type, obj, num)  \
82    (obj) ? ((type *) realloc((char *) obj, sizeof(type) * (num))) : \
83    ((type *) malloc(sizeof(type) * (num)))
84#define Cal_MemFree(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0)
85#else
86#define Cal_MemAlloc(type, num) ((type *) Cal_MemGetBlock(sizeof(type) * (num)))
87#define Cal_MemRealloc(type, obj, num)  \
88    (obj) ? ((type *) Cal_MemResizeBlock((Cal_Pointer_t) obj, sizeof(type) * (num))) : \
89    ((type *) Cal_MemGetBlock(sizeof(type) * (num)))
90#define Cal_MemFree(obj) ((obj) ? (Cal_MemFreeBlock((Cal_Pointer_t) (obj)), (obj) = 0) : 0)
91#endif
92#define Cal_MemCopy(dest, src, size)  ((void *) memcpy((void *)dest, (const void *)src, (size_t)size));
93#define Cal_MemZero(ptr, size) ((void)memset((void *)(ptr), 0, (Cal_Address_t)(size)))
94
95/* Round a size up for alignment */
96
97#define CAL_ROUNDUP(size) ((((size)+CAL_ALLOC_ALIGNMENT-1)/CAL_ALLOC_ALIGNMENT)*CAL_ALLOC_ALIGNMENT)
98
99/**AutomaticStart*************************************************************/
100
101/*---------------------------------------------------------------------------*/
102/* Function prototypes                                                       */
103/*---------------------------------------------------------------------------*/
104EXTERN void Cal_MemFatal(char *message);
105EXTERN Cal_Address_t Cal_MemAllocation(void);
106EXTERN Cal_Pointer_t Cal_MemGetBlock(Cal_Address_t size);
107EXTERN void Cal_MemFreeBlock(Cal_Pointer_t p);
108EXTERN Cal_Pointer_t Cal_MemResizeBlock(Cal_Pointer_t p, Cal_Address_t newSize);
109EXTERN Cal_Pointer_t Cal_MemNewRec(Cal_RecMgr mgr);
110EXTERN void Cal_MemFreeRec(Cal_RecMgr mgr, Cal_Pointer_t rec);
111EXTERN Cal_RecMgr Cal_MemNewRecMgr(int size);
112EXTERN void Cal_MemFreeRecMgr(Cal_RecMgr mgr);
113
114/**AutomaticEnd***************************************************************/
115
116#endif /* _CAL */
Note: See TracBrowser for help on using the repository browser.