1 |
dashley |
71 |
//$Header$ |
2 |
dashley |
244 |
//{9271a56e-a39a-4ba3-af90-c665b60de5e5} |
3 |
dashley |
71 |
//------------------------------------------------------------------------------------------------- |
4 |
dashley |
244 |
//This file is part of "Embedded Tool Set", a tool set designed to facilitate embedded system |
5 |
|
|
//software and hardware development. |
6 |
dashley |
71 |
//------------------------------------------------------------------------------------------------- |
7 |
|
|
//This source code and any program in which it is compiled/used is provided under the MIT License, |
8 |
|
|
//reproduced below. |
9 |
|
|
//------------------------------------------------------------------------------------------------- |
10 |
|
|
//Permission is hereby granted, free of charge, to any person obtaining a copy of |
11 |
|
|
//this software and associated documentation files(the "Software"), to deal in the |
12 |
|
|
//Software without restriction, including without limitation the rights to use, |
13 |
|
|
//copy, modify, merge, publish, distribute, sublicense, and / or sell copies of the |
14 |
|
|
//Software, and to permit persons to whom the Software is furnished to do so, |
15 |
|
|
//subject to the following conditions : |
16 |
|
|
// |
17 |
|
|
//The above copyright notice and this permission notice shall be included in all |
18 |
|
|
//copies or substantial portions of the Software. |
19 |
|
|
// |
20 |
|
|
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
21 |
|
|
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
22 |
|
|
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE |
23 |
|
|
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
24 |
|
|
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
25 |
|
|
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
26 |
|
|
//SOFTWARE. |
27 |
|
|
//------------------------------------------------------------------------------------------------- |
28 |
dashley |
234 |
#define MODULE_CMALLOC |
29 |
dashley |
71 |
|
30 |
|
|
#include <malloc.h> |
31 |
|
|
#include <process.h> |
32 |
|
|
#include <stdio.h> |
33 |
|
|
|
34 |
dashley |
234 |
#include "cmalloc.h" |
35 |
dashley |
71 |
|
36 |
dashley |
244 |
#include "../../c_cmode/ccmfatal.h" |
37 |
dashley |
71 |
|
38 |
|
|
|
39 |
dashley |
234 |
void *CMALLOC_malloc( size_t size ) |
40 |
dashley |
71 |
{ |
41 |
|
|
void *rv; |
42 |
|
|
|
43 |
|
|
rv = malloc(size); |
44 |
|
|
|
45 |
|
|
if (!rv) |
46 |
|
|
{ |
47 |
|
|
CCMFATAL_fatal("NULL pointer from malloc()--probable out of memory.", |
48 |
|
|
__FILE__, |
49 |
|
|
__LINE__); |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
return(rv); |
53 |
|
|
} |
54 |
|
|
|
55 |
|
|
|
56 |
dashley |
234 |
void *CMALLOC_calloc( size_t num, size_t size ) |
57 |
dashley |
71 |
{ |
58 |
|
|
void *rv; |
59 |
|
|
|
60 |
|
|
rv = calloc(num, size); |
61 |
|
|
|
62 |
|
|
if (!rv) |
63 |
|
|
{ |
64 |
|
|
CCMFATAL_fatal("NULL pointer from calloc()--probable out of memory.", |
65 |
|
|
__FILE__, |
66 |
|
|
__LINE__); |
67 |
|
|
} |
68 |
|
|
|
69 |
dashley |
234 |
return(rv); |
70 |
dashley |
71 |
} |
71 |
|
|
|
72 |
dashley |
234 |
void *CMALLOC_realloc( void *memblock, size_t size ) |
73 |
dashley |
71 |
{ |
74 |
|
|
void *rv; |
75 |
|
|
|
76 |
|
|
rv = realloc(memblock, size); |
77 |
|
|
|
78 |
|
|
if ((!rv) && (size)) |
79 |
|
|
{ |
80 |
|
|
CCMFATAL_fatal("NULL pointer from realloc()--probable out of memory.", |
81 |
|
|
__FILE__, |
82 |
|
|
__LINE__); |
83 |
|
|
} |
84 |
|
|
|
85 |
dashley |
234 |
return(rv); |
86 |
dashley |
71 |
} |
87 |
|
|
|
88 |
|
|
|
89 |
dashley |
234 |
void CMALLOC_free( void *memblock ) |
90 |
dashley |
71 |
{ |
91 |
|
|
free(memblock); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
|
95 |
dashley |
234 |
const char *CMALLOC_cvcinfo(void) |
96 |
dashley |
71 |
{ |
97 |
|
|
return("$Header$"); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
|
101 |
dashley |
234 |
const char *CMALLOC_hvcinfo(void) |
102 |
dashley |
71 |
{ |
103 |
dashley |
234 |
return(CMALLOC_H_VERSION); |
104 |
dashley |
71 |
} |
105 |
|
|
|
106 |
dashley |
234 |
//End of cmalloc.c. |