Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/algol60/src/utilities/sid/dalloc.h – Rev 7

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
7 7u83 2
 * Copyright (c) 2002-2005 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
7 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
7 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
7 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
7 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
7 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/**** dalloc.h --- Memory allocation and deallocation.
62
 *
63
 ** Author: Steve Folkes <smf@hermes.mod.uk>
64
 *
65
 **** Commentary:
66
 *
67
 ***=== INTRODUCTION =========================================================
68
 *
69
 * This file specifies the interface to a dynamic memory allocation facility.
70
 * All dynamically allocated objects are initialised with zeroes, but
71
 * non-integer typed fields will still need to be initialised explicitly.
72
 *
73
 * If the macro ``PO_DALLOC_DEBUG_ALIGN'' is defined, then extra debugging
74
 * information is added into the space allocated to help detect errors in
75
 * memory management.  If this macro is defined, it requires two functions to
76
 * be provided:
77
 *
78
 *	void				E_dalloc_multi_deallocate
7 7u83 79
 *			(GenericP, CStringP, unsigned, CStringP,
80
 *				  unsigned);
2 7u83 81
 *	void				E_dalloc_corrupt_block
7 7u83 82
 *			(GenericP, CStringP, unsigned);
2 7u83 83
 *
84
 * The first function will be called if a block is deallocated more than once.
85
 * It takes the block's address, and the file and line number of the
86
 * deallocation and allocation of the block as arguments.  The second function
87
 * is called if a block is corrupt when deallocated.  It takes the address of
88
 * the block and the file and line number of the deallocation of the block as
89
 * arguments.  Neither of these functions should return.
90
 *
91
 * This debugging mode should not be used on software that is shipped.  It has
92
 * machine specific implementations, and may be quite inefficient.
93
 *
94
 ***=== MACROS ===============================================================
95
 *
96
 ** Macro:	ALLOCATE (type)
97
 ** Exceptions:	XX_dalloc_no_memory
98
 *
99
 * This macro allocates an object of the specified type.  A pointer to the
100
 * object is returned.
101
 *
102
 ** Macro:	ALLOCATE_VECTOR (type, length)
103
 ** Exceptions:	XX_dalloc_no_memory
104
 *
105
 * This macro allocates a vector of the specified length containing objects of
106
 * the specified type.  A pointer to the first element in the vector is
107
 * returned.
108
 *
109
 ** Macro:	DEALLOCATE (pointer)
110
 ** Exceptions:
111
 *
112
 * This macro deallocates the specified pointer.  If the pointer is a null
113
 * pointer (``NIL (SomeTypeP)''), this does nothing.
114
 *
115
 ***=== EXCEPTIONS ===========================================================
116
 *
117
 ** Exception:	XX_dalloc_no_memory
118
 *
119
 * This exception is raised if there is not enough memory to allocate an
120
 * object (or a vector of objects).
121
 *
122
 **** Change Log:
123
 * $Log: dalloc.h,v $
124
 * Revision 1.1.1.1  1998/01/17  15:57:45  release
125
 * First version to be checked into rolling release.
126
 *
127
 * Revision 1.2  1994/12/12  11:45:30  smf
128
 * Performing changes for 'CR94_178.sid+tld-update' - bringing in line with
129
 * OSSG C Coding Standards.
130
 *
131
 * Revision 1.1.1.1  1994/07/25  16:06:09  smf
132
 * Initial import of os-interface shared files.
133
 *
134
**/
135
 
136
/****************************************************************************/
137
 
138
#ifndef H_DALLOC
139
#define H_DALLOC
140
 
141
#include "os-interface.h"
142
#include "exception.h"
143
 
144
/*--------------------------------------------------------------------------*/
145
 
146
extern ExceptionP		XX_dalloc_no_memory;
147
 
148
/*--------------------------------------------------------------------------*/
149
 
150
#ifdef PO_DALLOC_DEBUG_ALIGN
151
 
7 7u83 152
extern void	E_dalloc_multi_deallocate(GenericP, CStringP, unsigned,
153
					  CStringP, unsigned);
154
extern void	E_dalloc_corrupt_block(GenericP, CStringP, unsigned);
155
extern GenericP	X__dalloc_allocate(SizeT, SizeT, CStringP, unsigned);
156
extern void	X__dalloc_deallocate(GenericP, CStringP, unsigned);
2 7u83 157
 
158
#else
159
 
7 7u83 160
extern GenericP	X__dalloc_allocate(SizeT, SizeT);
2 7u83 161
 
162
#endif /* defined (PO_DALLOC_DEBUG_ALIGN) */
163
 
164
/*--------------------------------------------------------------------------*/
165
 
166
#ifdef PO_DALLOC_DEBUG_ALIGN
167
 
7 7u83 168
#define ALLOCATE(type)\
169
((type *)X__dalloc_allocate(sizeof(type), (SizeT)1, __FILE__, \
170
			     (unsigned)__LINE__))
2 7u83 171
 
7 7u83 172
#define ALLOCATE_VECTOR(type,length)\
173
((type *)X__dalloc_allocate(sizeof(type), (SizeT)(length), __FILE__, \
174
			     (unsigned)__LINE__))
2 7u83 175
 
7 7u83 176
#define DEALLOCATE(pointer)\
177
X__dalloc_deallocate((GenericP)(pointer), __FILE__, (unsigned)__LINE__)
2 7u83 178
 
179
#else
180
 
7 7u83 181
#define ALLOCATE(type)\
182
((type *)X__dalloc_allocate(sizeof(type), (SizeT)1))
2 7u83 183
 
7 7u83 184
#define ALLOCATE_VECTOR(type,length)\
185
((type *)X__dalloc_allocate(sizeof(type), (SizeT)(length)))
2 7u83 186
 
7 7u83 187
#define DEALLOCATE(pointer)\
188
if (pointer) {free((GenericP)(pointer));}
2 7u83 189
 
190
#endif /* defined (PO_DALLOC_DEBUG_ALIGN) */
191
 
192
#endif /* !defined (H_DALLOC) */