Home away from home ![Home away from home](https://www.amigans.net/uploads/rank3dbf8eb1a72e7.gif)
Joined: 2006/11/20 16:26 Last Login
: Yesterday 19:45
From Norway
Group:
Registered Users
|
@remotenemesis
You should be using AllocVecTags() for AmigaOS4.0 and newer, the older AllocVec() / AllocMem() don't have proper flags, for the new memory system.
(Should the memory be swappable, should the memory be executable and so on, memory alignment, should memory not be shared, should memory cleared.)
AllocMem() does not keep track of amount of memory you have allocated, so when you Free the memory you need keep that recorded, somewhere else. So here is postnasal of keep the wrong size somewhere, free the wrong number of block, resulting memory leeks or total failure, freeing blocks you should not have.
In most cases you might want to just use malloc() and free(), in clib, this work on all operating systems, unless you need a particular feature.
Small coding tip for new beginners:
Do not put all variable declaration of top functions, this common mistake. Variable declaration are initialized very time function is called, if the variable are not used, because of an "if" statement, then setting up that variable was not necessary.
Edited by LiveForIt on 2018/5/10 11:10:26 Edited by LiveForIt on 2018/5/10 11:12:52 Edited by LiveForIt on 2018/5/10 11:18:38 Edited by LiveForIt on 2018/5/10 11:21:05
|