Skip to content

Commit 078a129

Browse files
committed
tprintf: Make code reentrant and use less memory
Reduce the maximum message size from 64 KiB to 2 KiB which still should be large enought for trace messages. Create the smaller message on the stack instead of using a global array to allow reentrancy and to reduce the memory use of Tesseract. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent c926bdb commit 078a129

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/ccutil/tprintf.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* File: tprintf.cpp
33
* Description: Trace version of printf - portable between UX and NT
44
* Author: Phil Cheatle
5-
* Created: Wed Jun 28 15:01:15 BST 1995
65
*
76
* (C) Copyright 1995, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -29,7 +28,7 @@
2928
#include "strngs.h"
3029
#include "tprintf.h"
3130

32-
#define MAX_MSG_LEN 65536
31+
#define MAX_MSG_LEN 2048
3332

3433
static STRING_VAR(debug_file, "", "File to send tprintf output to");
3534

@@ -42,7 +41,7 @@ DLLSYM void tprintf(const char *format, ...)
4241
static FILE *debugfp = nullptr; // debug file
4342
// debug window
4443
int32_t offset = 0; // into message
45-
static char msg[MAX_MSG_LEN + 1];
44+
char msg[MAX_MSG_LEN + 1];
4645

4746
va_start(args, format); // variable list
4847
// Format into msg

0 commit comments

Comments
 (0)