All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
memry.cpp
Go to the documentation of this file.
1 /**********************************************************************
2  * File: memry.c (Formerly memory.c)
3  * Description: Memory allocation with builtin safety checks.
4  * Author: Ray Smith
5  * Created: Wed Jan 22 09:43:33 GMT 1992
6  *
7  * (C) Copyright 1992, Hewlett-Packard Ltd.
8  ** Licensed under the Apache License, Version 2.0 (the "License");
9  ** you may not use this file except in compliance with the License.
10  ** You may obtain a copy of the License at
11  ** http://www.apache.org/licenses/LICENSE-2.0
12  ** Unless required by applicable law or agreed to in writing, software
13  ** distributed under the License is distributed on an "AS IS" BASIS,
14  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  ** See the License for the specific language governing permissions and
16  ** limitations under the License.
17  *
18  **********************************************************************/
19 
20 #include "memry.h"
21 #include <stdlib.h>
22 
23 // With improvements in OS memory allocators, internal memory management
24 // is no longer required, so all these functions now map to their malloc
25 // family equivalents.
26 
27 // TODO(rays) further cleanup by redirecting calls to new and creating proper
28 // constructors.
29 
31  // Round up the amount allocated to a multiple of 4
32  return static_cast<char*>(malloc((count + 3) & ~3));
33 }
34 
35 void free_string(char *string) {
36  free(string);
37 }
38 
39 void* alloc_struct(inT32 count, const char *) {
40  return malloc(count);
41 }
42 
43 void free_struct(void *deadstruct, inT32, const char *) {
44  free(deadstruct);
45 }
46 
48  return malloc(static_cast<size_t>(count));
49 }
50 
52  return calloc(static_cast<size_t>(count), 1);
53 }
54 
55 void free_mem(void *oldchunk) {
56  free(oldchunk);
57 }
58 
59 void free_big_mem(void *oldchunk) {
60  free(oldchunk);
61 }
void free_mem(void *oldchunk)
Definition: memry.cpp:55
char * alloc_string(inT32 count)
Definition: memry.cpp:30
void free_big_mem(void *oldchunk)
Definition: memry.cpp:59
void free_string(char *string)
Definition: memry.cpp:35
void * alloc_struct(inT32 count, const char *)
Definition: memry.cpp:39
int count(LIST var_list)
Definition: oldlist.cpp:108
void * alloc_mem(inT32 count)
Definition: memry.cpp:47
void * alloc_big_zeros(inT32 count)
Definition: memry.cpp:51
void free_struct(void *deadstruct, inT32, const char *)
Definition: memry.cpp:43
int inT32
Definition: host.h:102