45 #include <config_auto.h>
48 #include "allheaders.h"
188 return ERROR_INT(
"numalloc not defined", __func__, 1);
190 if (nchunks > 1000.0)
191 L_WARNING(
"There are %.0f chunks\n", __func__, nchunks);
203 if ((
sizes = (
size_t *)LEPT_CALLOC(
nlevels,
sizeof(
size_t))) == NULL)
204 return ERROR_INT(
"sizes not made", __func__, 1);
216 return ERROR_INT(
"paa not made", __func__, 1);
223 if ((
baseptr = (l_uint32 *)LEPT_CALLOC(
nbytes / 4,
sizeof(l_uint32)))
225 return ERROR_INT(
"calloc fail for baseptr", __func__, 1);
230 return ERROR_INT(
"calloc fail for firstptr", __func__, 1);
234 for (i = 0; i <
nlevels; i++) {
236 return ERROR_INT(
"pa not made", __func__, 1);
239 for (j = 0; j < alloca[i]; j++) {
241 data +=
sizes[i] / 4;
248 pms->
memmax = (l_int32 *)LEPT_CALLOC(
nlevels,
sizeof(l_int32));
271 if ((pms = CustomPMS) == NULL)
286 LEPT_FREE(pms->
sizes);
317 if ((pms = CustomPMS) == NULL)
318 return (
void *)ERROR_PTR(
"pms not defined", __func__, NULL);
324 return (
void *)ERROR_PTR(
"data not made", __func__, NULL);
358 if ((pms = CustomPMS) == NULL) {
359 L_ERROR(
"pms not defined\n", __func__);
364 L_ERROR(
"level not found\n", __func__);
403 if ((pms = CustomPMS) == NULL)
404 return (
void *)ERROR_PTR(
"pms not defined", __func__, NULL);
406 if ((data = (
void *)LEPT_CALLOC(
nbytes,
sizeof(
char))) == NULL)
407 return (
void *)ERROR_PTR(
"data not made", __func__, NULL);
410 fprintf(fp,
"Alloc %zu bytes at %p\n",
nbytes, data);
413 L_ERROR(
"failed to open stream for %s\n", __func__, pms->
logfile);
436 return ERROR_INT(
"&level not defined", __func__, 1);
438 if ((pms = CustomPMS) == NULL)
439 return ERROR_INT(
"pms not defined", __func__, 1);
445 for (i = 0; i < pms->
nlevels; i++) {
473 return ERROR_INT(
"&level not defined", __func__, 1);
476 return ERROR_INT(
"data not defined", __func__, 1);
477 if ((pms = CustomPMS) == NULL)
478 return ERROR_INT(
"pms not defined", __func__, 1);
480 if (data < (
void *)pms->
baseptr || data >= (
void *)pms->
maxptr)
483 for (i = 1; i < pms->
nlevels; i++) {
485 if (data < (
void *)first)
503 if ((pms = CustomPMS) == NULL)
506 lept_stderr(
"Total number of pix used at each level\n");
507 for (i = 0; i < pms->
nlevels; i++)
511 lept_stderr(
"Max number of pix in use at any time in each level\n");
512 for (i = 0; i < pms->
nlevels; i++)
516 lept_stderr(
"Number of pix alloc'd because none were available\n");
517 for (i = 0; i < pms->
nlevels; i++)
l_int32 numaGetCount(NUMA *na)
numaGetCount()
l_int32 * numaGetIArray(NUMA *na)
numaGetIArray()
l_ok numaGetSum(NUMA *na, l_float32 *psum)
numaGetSum()
l_ok pmsCreate(size_t minsize, size_t smallest, NUMA *numalloc, const char *logfile)
pmsCreate()
void pmsLogInfo(void)
pmsLogInfo()
l_ok pmsGetLevelForAlloc(size_t nbytes, l_int32 *plevel)
pmsGetLevelForAlloc()
void pmsDestroy(void)
pmsDestroy()
void pmsCustomDealloc(void *data)
pmsCustomDealloc()
l_ok pmsGetLevelForDealloc(void *data, l_int32 *plevel)
pmsGetLevelForDealloc()
void * pmsCustomAlloc(size_t nbytes)
pmsCustomAlloc()
void * pmsGetAlloc(size_t nbytes)
pmsGetAlloc()
L_PTRAA * ptraaCreate(l_int32 n)
ptraaCreate()
L_PTRA * ptraCreate(l_int32 n)
ptraCreate()
l_ok ptraAdd(L_PTRA *pa, void *item)
ptraAdd()
void ptraaDestroy(L_PTRAA **ppaa, l_int32 freeflag, l_int32 warnflag)
ptraaDestroy()
L_PTRA * ptraaGetPtra(L_PTRAA *paa, l_int32 index, l_int32 accessflag)
ptraaGetPtra()
l_ok ptraaInsertPtra(L_PTRAA *paa, l_int32 index, L_PTRA *pa)
ptraaInsertPtra()
void * ptraRemoveLast(L_PTRA *pa)
ptraRemoveLast()
void lept_stderr(const char *fmt,...)
lept_stderr()
char * stringNew(const char *src)
stringNew()
FILE * fopenWriteStream(const char *filename, const char *modestring)
fopenWriteStream()