FUNCTION MemCAlloc( wItems AS DWORD, wBytes AS DWORD ) AS IntPtr
public static IntPtr MemCAlloc( uint wItems, uint wBytes )
|This function allows the direct manipulation of a memory location and should be used with extreme care.|
The Static Memory Functions (MemAlloc, MemSet etc) are included for compatibility only.
In most cases the static memory blocks can (and should) be replaced with arrays of bytes.|
Many of the functions in the runtime that take memory blocks as parameter, such as the low level IO functions, now have overloads that take arrays of bytes as parameter.
We recommend that you use these overloads, because their performance is somewhat better.
1LOCAL ptrLongs AS PTR 2ptrLongs := MemCAlloc(10, 4)
1ptrLongs := MemCAlloc(10, _SizeOf(LONG))
1STRUCTURE StatInfo 2 MEMBER wAverageHit AS DWORD 3 MEMBER wMaxHit AS DWORD 4 MEMBER wMinHit AS DWORD 5FUNCTION MemCAlloc2() AS VOID 6 LOCAL ptrStruct AS PTR 7 ptrStruct := MemCAlloc(5, _SizeOf(StatInfo)) 8 IF ptrStruct = NULL_PTR 9 ? "Allocation failed" 10 ELSE 11 MemFree(ptrStruct) 12 ENDIF
Copyright © 2015-2022 XSharp BV, All rights reserved. The VO SDK classes are Copyright © Computer Associates.