delorie.com/archives/browse.cgi | search |
From: | "A. Sinan Unur" <asu1 AT c-o-r-n-e-l-l DOT edu> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: Problem with malloc/free |
Date: | 3 Mar 2003 23:51:25 GMT |
Organization: | Cornell University |
Lines: | 38 |
Sender: | asu1 AT cornell DOT invalid (on pool-141-149-209-191.syr.east.verizon.net) |
Message-ID: | <Xns9333BFD40C77asu1cornelledu@132.236.56.8> |
References: | <3E6225AD DOT 1341CC2B AT ec-red DOT com> <Xns933270944F6EBasu1cornelledu AT 132 DOT 236 DOT 56 DOT 8> <3E62BFC8 DOT 4E12DED8 AT ec-red DOT com> |
NNTP-Posting-Host: | pool-141-149-209-191.syr.east.verizon.net |
X-Trace: | news01.cit.cornell.edu 1046735485 24454 141.149.209.191 (3 Mar 2003 23:51:25 GMT) |
X-Complaints-To: | usenet AT news01 DOT cit DOT cornell DOT edu |
NNTP-Posting-Date: | 3 Mar 2003 23:51:25 GMT |
User-Agent: | Xnews/5.04.25 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
Sergio Aguayo <sergioag AT ec-red DOT com> wrote in news:3E62BFC8 DOT 4E12DED8 AT ec-red DOT com: > No, i'm declaring an array of pointers: > > char *pcode[20]; > > then i allocate memory for each one in a "for" as follows: > > pcode[i] = (char*)malloc(length of file to load); > > when i finish, i call: > > free(pcode[i]); > > there's where the SIGSEGV occurs. I repeat: >> without some code that we can compile and diagnose, there is not much >> we can do. More suggestions: Make sure you are not writing past the end of allocated memory. How do you determine the length of the file? Are you sure the length you determined actually corresponds to the number of bytes you read in to the allocated buffer? Make sure you included <stdlib.h>, and lose the cast to (char *) in your malloc line (assuming you are writing C). Also, do consult the comp.lang.c FAQ. -- A. Sinan Unur asu1 AT c-o-r-n-e-l-l DOT edu Remove dashes for address Spam bait: mailto:uce AT ftc DOT gov
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |