tesseract
4.00.00dev
memry.cpp
Go to the documentation of this file.
1
/**********************************************************************
2
* File: memry.cpp (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
30
char
*
alloc_string
(
inT32
count
) {
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_mem
(
inT32
count
) {
40
return
malloc(static_cast<size_t>(count));
41
}
42
43
void
free_mem
(
void
*oldchunk) {
44
free(oldchunk);
45
}
free_string
void free_string(char *string)
Definition:
memry.cpp:35
free_mem
void free_mem(void *oldchunk)
Definition:
memry.cpp:43
count
int count(LIST var_list)
Definition:
oldlist.cpp:103
inT32
int32_t inT32
Definition:
host.h:38
memry.h
alloc_string
char * alloc_string(inT32 count)
Definition:
memry.cpp:30
alloc_mem
void * alloc_mem(inT32 count)
Definition:
memry.cpp:39
ccutil
memry.cpp
Generated on Wed Mar 28 2018 19:52:54 for tesseract by
1.8.13