TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: Kieran Haughey
date: 1996-01-19 12:35:10
subject: Re: Realloc

On 17 Jan 96 07:39, Frank Adam wrote to Kieran Haughey:

Hi Frank,

FA> G'Day Kieran,

FA> -=> Quoting Kieran Haughey to Frank Adam <=-

FA>> Geez, you'd think the man deserves two tiny capitals ? :)
KH>> Sorry.. :).. I do that sometimes.. :)
FA> It's ok, been called worse :)

kewl :)

KH>>> where cur_arr_size is something like 110..
KH>>> when it should have been
KH>>> realloc(fareas,cur_arr_size * sizeof(FA));
FA>>                     ^^^^^^^^^^^^   ^^^^^^^^^^
FA>> Don't forget to cast those to a long, if the allocated memory goes passed 
FA>> 655?? i forget:)..
FA>> it'll wrap around to 0 and that's what you'll allocate.Hence bye-bye data.

KH>> Well so far it's doing 1400 fine .. although I'll still 
KH>> cast them.. I think I may have anyway.. :)
FA> Well, you've seen the hiding i got from those two big bullies :)
FA> If you're using realloc(), it don't matter as long as cur_arr_size is 
FA> unsigned too.
FA> If you don't expect to use more than 64Ks realloc will be fine as above.

 I saw it, but I still think it's safer just to typecast them
even though your typecasting to the same type :).. but unfortunatly for
what I'm doing I need to alloc greater than 64K, to hold an array of 2000
:)..

KH>> H5, what happens if I declare it as an an unsigned int, and 
KH>> then typecast the sizeof to a unsigned int, do I still need 
KH>> to cast the cur_arr_size?..
FA> Sizeof already returns size_t, and cur_arr_size should be an unsigned for 
FA> realloc().
FA> Sizeof needs to be cast to a long and curarray declared long for 
FA> farrealloc()

So you were right :).. and those _BULLIES_ picked on you for nothing but
your lunch money :)..
ÿ
Cheers,
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™.