diff --git a/src/stdlib/SDL_malloc.c b/src/stdlib/SDL_malloc.c index 093a2a0e9..ebafb66cf 100644 --- a/src/stdlib/SDL_malloc.c +++ b/src/stdlib/SDL_malloc.c @@ -3463,7 +3463,9 @@ add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) msegmentptr ss = (msegmentptr) (chunk2mem(sp)); mchunkptr tnext = chunk_plus_offset(sp, ssize); mchunkptr p = tnext; +#ifdef DEBUG int nfences = 0; +#endif /* reset top to new space */ init_top(m, (mchunkptr) tbase, tsize - TOP_FOOT_SIZE); @@ -3481,13 +3483,17 @@ add_segment(mstate m, char *tbase, size_t tsize, flag_t mmapped) for (;;) { mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; +#ifdef DEBUG ++nfences; +#endif if ((char *) (&(nextp->head)) < old_end) p = nextp; else break; } +#ifdef DEBUG assert(nfences >= 2); +#endif /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) {