/[dtapublic]/projs/trunk/shared_source/c_cmode/ccmalloc.c
ViewVC logotype

Diff of /projs/trunk/shared_source/c_cmode/ccmalloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.55  
changed lines
  Added in v.71

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25