delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/30/04:46:48

From: "Rainer Temme" <N DOT O DOT S DOT P DOT A DOT M DOT temme AT kosmo DOT cgk DOT sni DOT de DOT N DOT O DOT S DOT P DOT A DOT M>
Newsgroups: comp.os.msdos.djgpp,comp.lang.c
Subject: Re: x/0, and a problem with realloc
Date: 30 Jan 1998 09:33:09 GMT
Organization: Siemens Nixdorf Inc.
Lines: 16
Message-ID: <01bd2d62$5c293010$2f9bca95@samos_pc2>
References: <Pine DOT LNX DOT 3 DOT 96 DOT 980130215217 DOT 25140A-100000 AT central DOT caverock DOT co DOT nz>
NNTP-Posting-Host: 149.202.155.47
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Original posting was about problems regarding calloc() / realloc()

>    CrArray=calloc(CrInFile, sizeof(long)

later on

>          CrArray=realloc(CrArray, j)
> /* This line seems to be causing problems -
>  * my array doesn't come out right... it gets mangled */

Regarding the code, I assume "j" is an index into the allocated array...
If this is the case, your realloc has to be
   realloc(CrArray,j*sizeof(long))

Regards Rainer

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019