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
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
#ifndef XALLOC_INCLUDED
32
#define XALLOC_INCLUDED
33
 
34
 
35
/*
36
    MEMORY ALLOCATION DECLARATIONS
37
 
38
    The routines in this module are concerned with the allocation of
39
    heap memory.
40
*/
41
 
42
extern gen_ptr xmalloc PROTO_S ( ( gen_size ) ) ;
43
extern gen_ptr xrealloc PROTO_S ( ( gen_ptr, gen_size ) ) ;
44
extern void xfree PROTO_S ( ( gen_ptr ) ) ;
45
extern string xustr PROTO_S ( ( gen_size ) ) ;
46
extern string xustrcpy PROTO_S ( ( string ) ) ;
47
extern string xustrncpy PROTO_S ( ( string, gen_size ) ) ;
48
extern string xustrcat PROTO_S ( ( string, string ) ) ;
49
extern void xufree PROTO_S ( ( string, gen_size ) ) ;
50
extern void xumemcpy PROTO_S ( ( string, string, gen_size ) ) ;
51
extern int xumemcmp PROTO_S ( ( string, string, gen_size ) ) ;
52
 
53
 
54
/*
55
    MACROS FOR ACCESSING MEMORY ALLOCATION ROUTINES
56
 
57
    These macros give a convenient method for accessing the routines above.
58
    For example, xmalloc_nof ( T, N ) allocates space for N objects of
59
    type T.
60
*/
61
 
62
#define xalloc_scale( T, N )\
63
	( ( gen_size ) ( N ) * ( gen_size ) sizeof ( T ) ) )
64
 
65
#define xmalloc_one( T )\
66
	( ( T * ) xmalloc ( xalloc_scale ( T, 1 ) )
67
 
68
#define xmalloc_nof( T, N )\
69
	( ( T * ) xmalloc ( xalloc_scale ( T, N ) )
70
 
71
#define xrealloc_nof( P, T, N )\
72
	( ( T * ) xrealloc ( ( gen_ptr ) ( P ), xalloc_scale ( T, N ) )
73
 
74
#define xfree_nof( P )\
75
	xfree ( ( gen_ptr ) ( P ) )
76
 
77
 
78
#endif