tesseract  4.00.00dev
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 
40  return malloc(static_cast<size_t>(count));
41 }
42 
44  return calloc(static_cast<size_t>(count), 1);
45 }
46 
47 void free_mem(void *oldchunk) {
48  free(oldchunk);
49 }
50 
51 void free_big_mem(void *oldchunk) {
52  free(oldchunk);
53 }
void free_mem(void *oldchunk)
Definition: memry.cpp:47
int32_t inT32
Definition: host.h:38
void free_big_mem(void *oldchunk)
Definition: memry.cpp:51
char * alloc_string(inT32 count)
Definition: memry.cpp:30
void * alloc_mem(inT32 count)
Definition: memry.cpp:39
void free_string(char *string)
Definition: memry.cpp:35
void * alloc_big_zeros(inT32 count)
Definition: memry.cpp:43
int count(LIST var_list)
Definition: oldlist.cpp:103