Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
 
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
Line 46... Line 76...
46
#include "common_types.h"
76
#include "common_types.h"
47
#include "basicread.h"
77
#include "basicread.h"
48
#include "messages_r.h"
78
#include "messages_r.h"
49
#include "xalloc.h"
79
#include "xalloc.h"
50
 
80
 
51
voidstar xcalloc
81
voidstar
52
    PROTO_N ( (n, s) )
-
 
53
    PROTO_T ( int n X size_t s )
82
xcalloc(int n, size_t s)
54
{
83
{
-
 
84
  voidstar v;
55
  if (n == 0)
85
  if (n == 0) {
56
    return ((voidstar) 0);
86
    return((voidstar)0);
57
  {
87
  }
-
 
88
 
58
    voidstar v = (voidstar) calloc ((size_t)n, s);
89
  v = (voidstar)calloc((size_t)n, s);
59
    if (v == (voidstar) 0) {
90
  if (v == (voidstar)0) {
60
      failer (NO_MEMORY);
91
    failer(NO_MEMORY);
61
      exit (EXIT_FAILURE);
92
    exit(EXIT_FAILURE);
62
    }
-
 
63
    return (v);
-
 
64
  }
93
  }
-
 
94
  return(v);
65
}
95
}
66
 
96
 
67
voidstar xrealloc
97
voidstar
68
    PROTO_N ( (p, s) )
-
 
69
    PROTO_T ( voidstar p X size_t s )
98
xrealloc(voidstar p, size_t s)
70
{
99
{
-
 
100
  voidstar v;
-
 
101
  
71
  voidstar v = (voidstar) realloc (p, s);
102
  v = (voidstar)realloc(p, s);
72
  if (v == (voidstar) 0) {
103
  if (v == (voidstar)0) {
73
    failer (NO_MEMORY);
104
    failer(NO_MEMORY);
74
    exit (EXIT_FAILURE);
105
    exit(EXIT_FAILURE);
75
  }
106
  }
76
  return v;
107
  return v;
77
}
108
}
78
 
109
 
79
void xfree
110
void
80
    PROTO_N ( (p) )
-
 
81
    PROTO_T ( voidstar p )
111
xfree(voidstar p)
82
{
112
{
83
   if (p)
113
   if (p) {
84
     free(p);
114
     free(p);
-
 
115
   }
85
   return;
116
   return;
86
}
117
}
87
 
118
 
88
voidstar xmalloc
119
voidstar
89
    PROTO_N ( (s) )
-
 
90
    PROTO_T ( size_t s )
120
xmalloc(size_t s)
91
{
121
{
-
 
122
  voidstar v;
-
 
123
  
92
  voidstar v = (voidstar) malloc (s);
124
  v = (voidstar)malloc(s);
93
  if (s != (size_t)0 && v == (voidstar) 0) {
125
  if (s != (size_t)0 && v == (voidstar)0) {
94
    failer (NO_MEMORY);
126
    failer(NO_MEMORY);
95
    exit (EXIT_FAILURE);
127
    exit(EXIT_FAILURE);
96
  }
128
  }
97
  return (v);
129
  return(v);
98
}
130
}