TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Paul Edwards
from: Kieran Haughey
date: 1995-12-24 14:24:26
subject: Realloc()

On 22 Dec 95 07:40, Paul Edwards wrote to Kieran Haughey:

Hi Paul,

PE>> Post a small program that demonstrates the bug.  For examples of

KH>>     arr_size_cur = 100;

KH>>     while(whatever)
KH>>     {
KH>>         /* any code whatever */
KH>>         if(count >= arr_size_cur && (count+10)>         {
KH>>             buffer = realloc(10,sizeof(char));
KH>>             arr_size_cur+=10;
KH>>         }

PE> Change this to 
PE> {
PE>     arr_size_cur += 10;
PE>     buffer = realloc(buffer, arr_size_cur)
PE> }

Argh.. I just  went through my online help and found out that I had it
figured wrong in my head :).. sorry about the previous message, I had
already packed it before I realised.. :).. I just managed to do a
successful example taking keys from the keyboard and loading them into an
array of 30 characters, which would realloc itself after every 10..  * 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™.