Login
Username:

Password:

Remember me



Lost Password?

Register now!
Main Menu
Who's Online
2 user(s) are online (1 user(s) are browsing Forum)

Members: 1
Guests: 1

Kalamatee, more...

Browsing this Thread:   1 Anonymous Users



(1) 2 »


realloc()?

Joined:
1/20 18:36
From SF Bay Area, California
Group:
Member
Posts: 35
Offline
A n00b question for you:


Unless I am missing something obvious, it appears that Exec does not support a realloc() analog?

Do I need to implement this myself when using AllocMem and FreeMem? Something like, AllocMem the new, mem copy old to new, FreeMem old then return pointer to new?

Am I missing another more Amiga-like option?

Thanks!

Posted on: 4/12 8:11
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
2004/10/30 17:13
From Ireland
Group:
Member
Posts: 2777
Offline
No, I don't think there's a function like that.

Posted on: 4/12 11:50
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
2016/8/16 0:09
Group:
Member
Posts: 328
Offline
Unless using a compiler (program language specific) that offers such functionality.

for example AROS' stdc implements realloc().

Posted on: 4/12 15:45
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
1/20 18:36
From SF Bay Area, California
Group:
Member
Posts: 35
Offline
So that'd be safe to use with memory allocated with AllocMem? Would make sense if it did I guess.

Posted on: 4/12 21:32
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
2005/8/17 16:00
From Germany
Group:
Member
Posts: 2221
Offline
Quote:

remotenemesis wrote:
So that'd be safe to use with memory allocated with AllocMem?


No. Don't mix C and Exec memory functions.

Posted on: 4/12 23:03
_________________
AROS - Make code, not war
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
1/20 18:36
From SF Bay Area, California
Group:
Member
Posts: 35
Offline
OK, it was trivial to implement using AllocMem, FreeMem and memcpy. Thank you!

Posted on: 4/13 23:04
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
2004/10/30 17:13
From Ireland
Group:
Member
Posts: 2777
Offline
Quote:

remotenemesis wrote:
OK, it was trivial to implement using AllocMem, FreeMem and memcpy. Thank you!


It would be more consistent to use CopyMem().

Posted on: 4/14 8:57
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
1/20 18:36
From SF Bay Area, California
Group:
Member
Posts: 35
Offline
Nice! Will do that thanks.

Posted on: 4/14 9:03
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
2016/8/16 0:09
Group:
Member
Posts: 328
Offline
Quote:

mazze wrote:
Quote:

remotenemesis wrote:
So that'd be safe to use with memory allocated with AllocMem?


No. Don't mix C and Exec memory functions.

To elaborate: c uses it's own memory manager, and mixing those with api calls would interfere with its 'management'.

In that respect my link was meant to show you that it is trivial to implement

Posted on: 4/14 10:47
Transfer the post to other applications Transfer


Re: realloc()?

Joined:
1/20 18:36
From SF Bay Area, California
Group:
Member
Posts: 35
Offline
I missed your link earlier. Thanks for that.


Posted on: 4/14 11:55
Transfer the post to other applications Transfer



(1) 2 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.

[Advanced Search]


Search
Top Posters
1 paolone
paolone
4405
2 magorium
magorium
4095
3 nikolaos
nikolaos
3962
4 phoenixkonsole
phoenixkonsole
3903
5 deadwood
deadwood
2917
6 ncafferkey
ncafferkey
2777
7 mazze
mazze
2221
8 Kalamatee
Kalamatee
2139
9 clusteruk
clusteruk
2112
10 damocles
damocles
1789
© 2004-2018 AROS Exec