Why does MemorySize on Array throws error

Just starting out? Need help? Post your questions and find answers here.
Nituvious
Addict
Addict
Posts: 1030
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Why does MemorySize on Array throws error

Post 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?
▓▓▓▓▓▒▒▒▒▒░░░░░
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Re: Why does MemorySize on Array throws error

Post 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)
Nituvious
Addict
Addict
Posts: 1030
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Why does MemorySize on Array throws error

Post 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.
▓▓▓▓▓▒▒▒▒▒░░░░░
Post Reply