Memory ID of Memory Address

Everything else that doesn't fall into one of the other PB categories.
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Memory ID of Memory Address

Post by Codemonger »

Is their a function to get the memoryID of the address --

Lets say I wan't to store the memory address of the memory ID .. no problem ... But later in my program I would like to use that address to find out the Memory ID it belongs to. Anyone have a solutions or is it already available and I'm just missing it ?

I could recurse a list of memory ID's and check if I get a match, but that seems time consuming or I could build a structure to represent both the MemoryAddress and the ID it belongs to ... ohh thats not such a bad idea, then I could pass the address of the structure to my procedures and create a dummy pointer to the structure .... that might work.

Code: Select all

Structure PBMemory
   MemID.l
   MemAddress.l
EndStructure
Any other ideas ?
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Re: Memory ID of Memory Address

Post by tinman »

Codemonger wrote:Any other ideas ?
Store a linked list of your structures. That's probably what PB would have to do internally in the linked list library if it wanted to look up memory ID to bank number.

Bank numbers for memory are a complete pain in the ass if you're doing anything relaitively dynamic. Any news on the #PB_BANK_NUMBER_I_DONT_CARE option for the memory lib Fred?
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

You right Tinman they are a pain in the ass, and I am doing dynamic stuff. I only needed the MemoryID to reallocate memory and or to compare memory ... I think, now I can't remember why I needed it ? Oh I'll stumble across it programming today :?:

But what I do like is the automatic allocation and flag setting, also the automatic deletion of the memory when the program ends. I don't have to worry about anything.
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
Post Reply