Setting pointer value to another pointer

BlitzMax Forums/BlitzMax Programming/Setting pointer value to another pointer

Bot Builder(Posted 2005) [#1]
No setting them to point at the same thing, but setting the memory located at one pointer to be a pointer to other memory:

Global Pointers:Int Ptr=MemAlloc(1024*4)
Pointers[0]=Int(MemAlloc(1024))
[ERROR]: Compile Error:Unable to convert from 'Byte Ptr' to 'Int Ptr'
On the second line. However, I'm not trying to do this. I'm attempting to set an int to an int...

[EDIT] BTW, yes, I am crazy for doing this. After my second attempt at string split functionality I've gone all out as far as speed goes. Its gonna have a custom memory system, alloced when needed, minimum of 1K, max 1 mb, used instead of arrays inside the split function, so the arrays dont have to be alloced/dealloced every call and there isn't a limit on the size of the input text or split elements. I think this is the best way. If I cannot do this, banks or arrays will do fine instead for the main pointer list.


ImaginaryHuman(Posted 2005) [#2]
local firstpointer:int ptr
firstpointer=whatever
intvalue=firstpointer[0] 'get the content of where the pointer points
secondpointer=int ptr(intvalue)

something like that


Bot Builder(Posted 2005) [#3]
Nevermind I'll just use an array :P

Angel - thanks, but, that just retrieves the value of a variable if such a system as above was created.


ImaginaryHuman(Posted 2005) [#4]
Oh, so you want to allocate a memory buffer and then fill it with pointers to other memory buffers?

MemAlloc() returns a Byte Ptr, so you might need something like:

Global Pointers:Int Ptr=Int Ptr(MemAlloc(1024*4)) '1024 pointers
Pointers[0]=Int(Int Ptr(MemAlloc(1024)) 'store a pointer

?????? Of course, if you decided to use another method that's okay too.

I was finding that for certain conversions you need to translate the byte pointer to an int pointer first.