Skip to content

Commit 20e243d

Browse files
committed
strngs: Replace alloc_mem, free_mem by standard functions
Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent 8953f41 commit 20e243d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/ccutil/strngs.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
#include "strngs.h"
2121
#include <cassert> // for assert
22+
#include <cstdlib> // for malloc, free
2223
#include "errcode.h" // for ASSERT_HOST
2324
#include "genericvector.h" // for GenericVector
2425
#include "helpers.h" // for ReverseN
25-
#include "memry.h" // for alloc_string, free_string
2626
#include "serialis.h" // for TFile
2727

2828
using tesseract::TFile;
@@ -51,7 +51,7 @@ const int kMaxDoubleSize = 16;
5151
const int kMinCapacity = 16;
5252

5353
char* STRING::AllocData(int used, int capacity) {
54-
data_ = (STRING_HEADER *)alloc_string(capacity + sizeof(STRING_HEADER));
54+
data_ = (STRING_HEADER *)malloc(capacity + sizeof(STRING_HEADER));
5555

5656
// header is the metadata for this memory block
5757
STRING_HEADER* header = GetHeader();
@@ -61,7 +61,8 @@ char* STRING::AllocData(int used, int capacity) {
6161
}
6262

6363
void STRING::DiscardData() {
64-
free_string((char *)data_);
64+
free(data_);
65+
data_ = nullptr;
6566
}
6667

6768
// This is a private method; ensure FixHeader is called (or used_ is well defined)
@@ -78,7 +79,7 @@ char* STRING::ensure_cstr(int32_t min_capacity) {
7879
min_capacity = 2 * orig_header->capacity_;
7980

8081
int alloc = sizeof(STRING_HEADER) + min_capacity;
81-
STRING_HEADER* new_header = (STRING_HEADER*)(alloc_string(alloc));
82+
STRING_HEADER* new_header = (STRING_HEADER*)(malloc(alloc));
8283

8384
memcpy(&new_header[1], GetCStr(), orig_header->used_);
8485
new_header->capacity_ = min_capacity;

0 commit comments

Comments
 (0)