Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!cluster!metro!bunyip!moondance!uqcspe!qfagus!gordon From: gordon@qfagus.OZ (Peter Gordon) Newsgroups: comp.lang.c Subject: Turboc Malloc Keywords: Turboc Malloc Message-ID: <26317@qfagus.OZ> Date: 27 Feb 90 21:51:32 GMT Organization: Department of Forestry, Brisbane, Australia Lines: 20 > Please tell me I'm doing something stupid. > head = (char **)malloc(200 * sizeof(char **)); > for(cp = head, i = 0; i < 200; ++i, ++cp) > { > fprintf(stdout,"Freeing %d\n", i); > fflush(stdout); > free(cp); > } > } My face is red, as suspected the fault is mine and is stupid. I'm freeing a pointer and THEN trying to increment it. Code something like: X for(cp = &head[198]; cp >= head; --cp) X free(cp + 1); X free(head); works as expected. People abuse the bugs in compilers, but in many instances, they are very forgiving of fools such as I. Peter Gordon