58 return(*((
const int *)i) - *((
const int *)j));
93 void **freelistp, *newbuffer;
99 qh_fprintf(qh, qh->
qhmem.
ferr, 6235,
"qhull error (qh_memalloc): negative request size (%d). Did int overflow due to high-D?\n", insize);
107 if ((
object= *freelistp)) {
110 *freelistp= *((
void **)*freelistp);
125 if (!(newbuffer=
qh_malloc((
size_t)bufsize))) {
126 qh_fprintf(qh, qh->
qhmem.
ferr, 6080,
"qhull error (qh_memalloc): insufficient memory to allocate short memory buffer (%d bytes)\n", bufsize);
156 qh_fprintf(qh, qh->
qhmem.
ferr, 6081,
"qhull internal error (qh_memalloc): qhmem has not been initialized.\n");
164 if (!(
object=
qh_malloc((
size_t)outsize))) {
165 qh_fprintf(qh, qh->
qhmem.
ferr, 6082,
"qhull error (qh_memalloc): insufficient memory to allocate %d bytes\n", outsize);
181 int i, count, totfree= 0;
185 qh_fprintf_stderr(6243,
"qh_memcheck(qh) error: qh is 0. It does not point to a qhT");
189 qh_fprintf_stderr(6244,
"qh_memcheck error: either qh->qhmem is overwritten or qh->qhmem is not initialized. Call qh_mem_new() or qh_new_qhull() before calling qh_mem routines. ferr 0x%x IsTracing %d ALIGNmask 0x%x", qh->
qhmem.
ferr, qh->
qhmem.
IStracing, qh->
qhmem.
ALIGNmask);
193 qh_fprintf(qh, qh->
qhmem.
ferr, 8143,
"qh_memcheck: check size of freelists on qh->qhmem\nqh_memcheck: A segmentation fault indicates an overwrite of qh->qhmem\n");
196 for (
object= qh->
qhmem.
freelists[i];
object;
object= *((
void **)
object))
205 qh_fprintf(qh, qh->
qhmem.
ferr, 8144,
"qh_memcheck: total size of freelists totfree is the same as qh->qhmem.totfree\n", totfree);
239 *((
void **)
object)= *freelistp;
275 void *buffer, *nextbuffer;
281 nextbuffer= *((
void **) buffer);
291 memset((
char *)&qh->
qhmem, 0,
sizeof(qh->
qhmem));
305 memset((
char *)&qh->
qhmem, 0,
sizeof(qh->
qhmem));
310 if (
sizeof(
void*) <
sizeof(
int)) {
311 qh_fprintf(qh, qh->
qhmem.
ferr, 6083,
"qhull internal error (qh_meminit): sizeof(void*) %d < sizeof(int) %d. qset.c will not work\n", (
int)
sizeof(
void*), (
int)
sizeof(
int));
314 if (
sizeof(
void*) >
sizeof(
ptr_intT)) {
315 qh_fprintf(qh, qh->
qhmem.
ferr, 6084,
"qhull internal error (qh_meminit): sizeof(void*) %d > sizeof(ptr_intT) %d. Change ptr_intT in mem.h to 'long long'\n", (
int)
sizeof(
void*), (
int)
sizeof(
ptr_intT));
340 qh_fprintf(qh, qh->
qhmem.
ferr, 6085,
"qhull internal error (qh_meminit): memory alignment %d is not a power of 2\n", alignment);
343 qh->
qhmem.
sizetable= (
int *) calloc((
size_t)numsizes,
sizeof(int));
344 qh->
qhmem.
freelists= (
void **) calloc((
size_t)numsizes,
sizeof(
void *));
350 qh_fprintf(qh, qh->
qhmem.
ferr, 8059,
"qh_meminitbuffers: memory initialized with alignment %d\n", alignment);
365 qh_fprintf(qh, qh->
qhmem.
ferr, 6087,
"qhull error (qh_memsetup): largest mem size %d is >= buffer size %d or initial buffer size %d\n",
394 qh_fprintf(qh, qh->
qhmem.
ferr, 6089,
"qhull error (qh_memsize): called after qhmem_setup\n");
423 qh_fprintf(qh, fp, 9278,
"\nmemory statistics:\n\ 424 %7d quick allocations\n\ 425 %7d short allocations\n\ 426 %7d long allocations\n\ 429 %7d bytes of short memory in use\n\ 430 %7d bytes of short memory in freelists\n\ 431 %7d bytes of dropped short memory\n\ 432 %7d bytes of unused short memory (estimated)\n\ 433 %7d bytes of long memory allocated (max, except for input)\n\ 434 %7d bytes of long memory in use (in %d pieces)\n\ 435 %7d bytes of short memory buffers (minus links)\n\ 436 %7d bytes per short memory buffer (initially %d bytes)\n",
444 qh_fprintf(qh, fp, 9279,
"%7d calls to qh_setlarger\n%7.2g average copy size\n",
446 qh_fprintf(qh, fp, 9280,
" freelists(bytes->count):");
450 for (
object= qh->
qhmem.
freelists[i];
object;
object= *((
void **)
object))
472 if (!(
object=
qh_malloc((
size_t)insize))) {
499 memset((
char *)&qh->
qhmem, 0,
sizeof(qh->
qhmem));
504 memset((
char *)&qh->
qhmem, 0,
sizeof(qh->
qhmem));
509 if (
sizeof(
void*) <
sizeof(
int)) {
510 qh_fprintf(qh, qh->
qhmem.
ferr, 6091,
"qhull internal error (qh_meminit): sizeof(void*) %d < sizeof(int) %d. qset.c will not work\n", (
int)
sizeof(
void*), (
int)
sizeof(
int));
515 void qh_meminitbuffers(
qhT *qh,
int tracelevel,
int alignment,
int numsizes,
int bufsize,
int bufinit) {
530 qh_fprintf(qh, fp, 9409,
"\nmemory statistics:\n\ 531 %7d long allocations\n\ 533 %7d bytes of long memory allocated (max, except for input)\n\ 534 %7d bytes of long memory in use (in %d pieces)\n",
554 void qh_memtotal(
qhT *qh,
int *totlong,
int *curlong,
int *totshort,
int *curshort,
int *maxlong,
int *totbuffer) {
void * qh_malloc(size_t size)
void qh_fprintf_stderr(int msgcode, const char *fmt,...)
void qh_fprintf(FILE *fp, int msgcode, const char *fmt,...)
void qh_memfreeshort(qhT *qh, int *curlong, int *totlong)
void qh_memsetup(qhT *qh)
void qh_memfree(qhT *qh, void *object, int insize)
void qh_memsize(qhT *qh, int size)
void qh_exit(int exitcode)
void qh_meminitbuffers(qhT *qh, int tracelevel, int alignment, int numsizes, int bufsize, int bufinit)
void * qh_memalloc(qhT *qh, int insize)
void qh_memtotal(qhT *qh, int *totlong, int *curlong, int *totshort, int *curshort, int *maxlong, int *totbuffer)
void qh_memstatistics(qhT *qh, FILE *fp)
void qh_errexit(int exitcode, facetT *facet, ridgeT *ridge)
static int qh_intcompare(const void *i, const void *j)
void qh_memcheck(qhT *qh)
void qh_meminit(qhT *qh, FILE *ferr)