From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: Symify crash Date: Fri, 18 Aug 2000 19:57:04 +0100 Organization: Customer of Energis Squared Lines: 27 Message-ID: References: <3 DOT 0 DOT 5 DOT 32 DOT 20000813122244 DOT 007c0c00 AT pop DOT mail DOT yahoo DOT com> <3405-Sun13Aug2000163046+0300-eliz AT is DOT elta DOT co DOT il> <3996E3F4 DOT C9B37F8B AT softhome DOT net> <2593-Sun13Aug2000214525+0300-eliz AT is DOT elta DOT co DOT il> <7704-Fri18Aug2000203741+0300-eliz AT is DOT elta DOT co DOT il> NNTP-Posting-Host: modem-39.dorwinion.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news5.svr.pol.co.uk 966625044 21108 62.136.157.167 (18 Aug 2000 18:57:24 GMT) NNTP-Posting-Date: 18 Aug 2000 18:57:24 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com "Eli Zaretskii" wrote: > > I've no idea if this has anything to do with the problem discussed, > > but the following code from syms.c lines 362-365 does indeed show some > > data which is failing to be initialised: > > > > syms = (SymNode *)malloc(num_syms * sizeof(SymNode)); > > memset(syms, num_syms * sizeof(SymNode), 0); > > files = (FileNode *)malloc(num_files * sizeof(FileNode)); > > memset(files, num_files * sizeof(FileNode), 0); > > I must be missing something, because I don't see what's not > initialized here. Care to point it out? void *memset(void *buffer, int ch, size_t num); The 2nd & 3rd arguments to memset are reversed. Also, ISTR that generally accepted best practice is *not* to cast the return from malloc() so the code should read: syms = malloc(num_syms * sizeof(SymNode)); memset(syms, 0, num_syms * sizeof(SymNode)); files = malloc(num_files * sizeof(FileNode)); memset(files, 0, num_files * sizeof(FileNode)); Or use calloc().