delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/20/04:55:28

From: Edward Hill <ha AT nochance DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: A Structured Problem ?
Date: Tue, 20 Jul 1999 09:18:07 +0100
Organization: GEC-Marconi
Lines: 36
Message-ID: <379430BF.4B633E7D@nochance.com>
References: <7mv0te$gq2$1 AT news6 DOT svr DOT pol DOT co DOT uk> <Pine DOT SUN DOT 3 DOT 96 DOT 990719090429 DOT 29235A-100000 AT silver DOT cs DOT umanitoba DOT ca> <7n09p0$9db$1 AT news5 DOT svr DOT pol DOT co DOT uk>
NNTP-Posting-Host: pc02372.gmsws.gecm.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.51 [en] (Win95; I)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Paul J G wrote:
: 
: Many thanks to everybody, everythings running fine now. Although
perhaps you
: could be so kind as to answer these questions for me.
: 
: 1) How would I use the free command to free up one of the shape
indentifiers
: or to delete
:     the whole structure ?.

You shaould call free once for every item malloc'ed.
So,
void freemyshape(int shapeno)
{
      if(shape[shapeno].xpoint != NULL) free(shape[shapeno].xpoint);
      if(shape[shapeno].ypoint != NULL) free(shape[shapeno].ypoint);
}

assuming is global otherwise you'll have to pass the shape to
the function. 
: 2) Both Michael and Ed used slightly different malloc commands, whats
the
: difference ?.

Michael was casting the return of malloc, which is a bad idea in C I
assume
he was writing in C++.
 
: 3) If I am writing for a machine with 32 megs and want to use, say 3
megs
: for holding my shape data in would I use FARMALLOC command instead ?.

no malloc should suit you fine. DJGPP is good like that.

Ed

- Raw text -


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