44 #include "allheaders.h" 183 PROCNAME(
"createPMS");
186 return ERROR_INT(
"numalloc not defined", procName, 1);
188 if (nchunks > 1000.0)
189 L_WARNING(
"There are %.0f chunks\n", procName, nchunks);
193 return ERROR_INT(
"pms not made", procName, 1);
203 if ((
sizes = (
size_t *)LEPT_CALLOC(
nlevels,
sizeof(
size_t))) == NULL)
204 return ERROR_INT(
"sizes not made", procName, 1);
216 return ERROR_INT(
"paa not made", procName, 1);
223 if ((
baseptr = (l_uint32 *)LEPT_CALLOC(
nbytes / 4,
sizeof(l_uint32)))
225 return ERROR_INT(
"calloc fail for baseptr", procName, 1);
230 return ERROR_INT(
"calloc fail for firstptr", procName, 1);
234 for (i = 0; i <
nlevels; i++) {
236 return ERROR_INT(
"pa not made", procName, 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);
318 PROCNAME(
"pmsCustomAlloc");
320 if ((pms = CustomPMS) == NULL)
321 return (
void *)ERROR_PTR(
"pms not defined", procName, NULL);
327 return (
void *)ERROR_PTR(
"data not made", procName, NULL);
361 PROCNAME(
"pmsCustomDealloc");
363 if ((pms = CustomPMS) == NULL) {
364 L_ERROR(
"pms not defined\n", procName);
369 L_ERROR(
"level not found\n", procName);
412 PROCNAME(
"pmsGetAlloc");
414 if ((pms = CustomPMS) == NULL)
415 return (
void *)ERROR_PTR(
"pms not defined", procName, NULL);
417 if ((data = (
void *)LEPT_CALLOC(
nbytes,
sizeof(
char))) == NULL)
418 return (
void *)ERROR_PTR(
"data not made", procName, NULL);
421 fprintf(fp,
"Alloc %lu bytes at %p\n", (
unsigned long)
nbytes, data);
444 PROCNAME(
"pmsGetLevelForAlloc");
447 return ERROR_INT(
"&level not defined", procName, 1);
449 if ((pms = CustomPMS) == NULL)
450 return ERROR_INT(
"pms not defined", procName, 1);
456 for (i = 0; i < pms->
nlevels; i++) {
483 PROCNAME(
"pmsGetLevelForDealloc");
486 return ERROR_INT(
"&level not defined", procName, 1);
489 return ERROR_INT(
"data not defined", procName, 1);
490 if ((pms = CustomPMS) == NULL)
491 return ERROR_INT(
"pms not defined", procName, 1);
493 if (data < (
void *)pms->
baseptr || data >= (
void *)pms->
maxptr)
496 for (i = 1; i < pms->
nlevels; i++) {
498 if (data < (
void *)first)
516 if ((pms = CustomPMS) == NULL)
519 fprintf(stderr,
"Total number of pix used at each level\n");
520 for (i = 0; i < pms->
nlevels; i++)
521 fprintf(stderr,
" Level %d (%lu bytes): %d\n", i,
524 fprintf(stderr,
"Max number of pix in use at any time in each level\n");
525 for (i = 0; i < pms->
nlevels; i++)
526 fprintf(stderr,
" Level %d (%lu bytes): %d\n", i,
529 fprintf(stderr,
"Number of pix alloc'd because none were available\n");
530 for (i = 0; i < pms->
nlevels; i++)
531 fprintf(stderr,
" Level %d (%lu bytes): %d\n", i,
l_ok numaGetSum(NUMA *na, l_float32 *psum)
numaGetSum()
void ptraaDestroy(L_PTRAA **ppaa, l_int32 freeflag, l_int32 warnflag)
ptraaDestroy()
char * stringNew(const char *src)
stringNew()
void * pmsCustomAlloc(size_t nbytes)
pmsCustomAlloc()
void pmsCustomDealloc(void *data)
pmsCustomDealloc()
void * ptraRemoveLast(L_PTRA *pa)
ptraRemoveLast()
l_ok pmsGetLevelForAlloc(size_t nbytes, l_int32 *plevel)
pmsGetLevelForAlloc()
l_int32 * numaGetIArray(NUMA *na)
numaGetIArray()
L_PTRA * ptraCreate(l_int32 n)
ptraCreate()
l_int32 numaGetCount(NUMA *na)
numaGetCount()
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 pmsLogInfo()
pmsLogInfo()
l_ok pmsCreate(size_t minsize, size_t smallest, NUMA *numalloc, const char *logfile)
pmsCreate()
void * pmsGetAlloc(size_t nbytes)
pmsGetAlloc()
FILE * fopenWriteStream(const char *filename, const char *modestring)
fopenWriteStream()
l_ok ptraAdd(L_PTRA *pa, void *item)
ptraAdd()
void pmsDestroy()
pmsDestroy()
l_ok pmsGetLevelForDealloc(void *data, l_int32 *plevel)
pmsGetLevelForDealloc()
L_PTRAA * ptraaCreate(l_int32 n)
ptraaCreate()