TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Paul Edwards
from: Kieran Haughey
date: 1995-12-21 11:08:44
subject: Realloc()

On 19 Dec 95 22:36, Paul Edwards wrote to Kieran Haughey:

Hi Paul,

KH>> I can't remember if realloc has one or two varibles for it, I think it's 

PE> 1. Look in the header file stdlib.h

Faster to look in online help :). and it's two from memory.. last time I
checked which was right about writing that message..

PE> 2. FREQ ANSI_C.* from 3:711/934.

 ok I will...

KH>> right..  The main reason I'm after an example, is because my previous 
KH>> attempts at doing this failed, ended up getting exception errors...

PE> Post a small program that demonstrates the bug.  For examples of
PE> using realloc(), get the vast amounts of source code available
PE> for FREQ from 3:711/934.

it was more a problem of missing the allocation of an array, but the
program still accessing it..

what I want is something like this

#define ARR_SIZE 2000
int main()
{
    char *buffer;
    long arr_size_cur=0;
    long count=0;

    buffer = calloc(100,sizeof(char));
    arr_size_cur = 100;

    while(whatever)
    {
        /* any code whatever */
        if(count >= arr_size_cur && (count+10)=ARR_SIZE)
            break;
        count++;
    }
    free(buffer);
    return 0;
}

That sort of idea, what I really want is a better way of writing it, also
one which will alloc all members of the array, and not miss any.. 

I would send you the source I have done so far of my program, but there's
to much to it.. .. 

I just really need a decent example of how to realloc a varible to extend
it when needed...
            
ÿ
Merry Christmas,
Kieran

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

--- MsgedSQ 3.30
* 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 808 809
SEEN-BY: 711/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™.