Page 1 of 1

Why does MemorySize on Array throws error

Posted: Sat Mar 19, 2011 7:20 am
by Nituvious

Code: Select all

Structure mem
	*Pointer
EndStructure

Dim MyArray.mem(1)

ReAllocateMemory(MyArray(1)\Pointer,10)

Debug MemorySize(MyArray(1)\Pointer)
Why does this return invalid MemoryID? Is it not legal to use a pointer inside of a structure and attach to an array?

Re: Why does MemorySize on Array throws error

Posted: Sat Mar 19, 2011 9:06 am
by eesau
ReAllocateMemory returns a new pointer, which you must assign first.

Code: Select all

Structure mem
   *Pointer
EndStructure

Dim MyArray.mem(1)

MyArray(1)\Pointer = ReAllocateMemory(MyArray(1)\Pointer,10)

Debug MemorySize(MyArray(1)\Pointer)

Re: Why does MemorySize on Array throws error

Posted: Sat Mar 19, 2011 9:34 am
by Nituvious
"I see.", said the blind man. :oops:
Thanks for the tip, I didn't know that. I'm fairly inexperienced with pointers and memory.