TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: All
from: Kieran Haughey
date: 1995-12-18 08:59:16
subject: Realloc()

Hi All,

I was wondering if someone might be able to give me an example of how to
use realloc, I have an example from TC++'s online help, but it doesn't do
what I need, 

I want to create an array of a structure with 100 members 
in it, I then want to fill it with information, and reallocate it by 30
each time it's needed untill the array size is less then a defined size


something like this

FA huge *fareas;
int main()
{
    fareas = farcalloc(100,sizeof FA);
    fillstruct();
}

and within fillstruct() i'd have a loop like the following

x=0;
while(!done)
{
    loadmember(fareas[x]);
    x++;
    if(x>=curr_array_size && x < ARR_SIZE)
    {
        fareas = farrealloc(30,sizeof FA);
        curr_array_size+=30;
    }
}

I can't remember if realloc has one or two varibles for it, I think it's
right..  The main reason I'm after an example, is because my previous
attempts at doing this failed, ended up getting exception errors...

But I'll try it again.  

Merry Christmas,
Kieran

3:711/413.17{at}fidonet
@EOT:

--- MsgedSQ 3.30 alpha 5
* Origin: -=> The Last Stand Against Sanity <=- (3:711/413.17)
SEEN-BY: 50/99 620/243 623/630 711/401 409 410 413 420 423 430 510 807 808
SEEN-BY: 711/809 932 934 712/515 713/888 714/906 800/1 7877/2809
@PATH: 711/413 808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.