RE: TK_mem problem and replacement
- Posted by Matthew Lewis <matthewwalkerlewis at YAHOO.COM> Jun 24, 2002
- 400 views
> -----Original Message----- > From: jordah ferguson [mailto:jorfergie03 at yahoo.com] > B4, you read this, i have written a tk_mem.e replacement but > using pure > euphoria code. It is fast and is still undergoing a series of > tests. It > is safer and faster than the original tk_mem. Soon to be > released on RDS One of the reasons tk_mem was written was to use the memory management of windows, which has the capability to return RAM to the OS when you're done with it. > -- What if you are allocating a Byte,Strz or Word? They would still be > -- forced to take 4 bytes of memory with below code You're going to always allocate 4 bytes (even if you only ask for 1). Everything is 4-byte aligned. > If Yes, pData should be a minimum of 4 Bytes. Why bother with > > if pData != 0 then > pData = vSizeLengs[pData] > end if Here, pData is originally an index into vSizeLengs. Derek then makes sure that you're asking for at least 4 bytes (you might have wanted more). I suspect that he's left this in just in case he ever codes in a datatype with more than 4 bytes. Then, he only needs to add it to vSizeNames/vSizeLengs. It might be appropriate to return an error if pData = 0, since this indicates that the user specified an unknown datatype. Matt Lewis