Memory Bank Numbering

Everything else that doesn't fall into one of the other PB categories.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

If I want to reserve a mem bank and avoid conflict is it ok to use
say 999 as mem bank number, ie, PB won't go creating 998 other
entries in a table somewhere? I expect PB is using a linked list
to store -to- pairings but thought I'd
ask because I may end up using a very large mem bank number.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.
Originally posted by dmoc

If I want to reserve a mem bank and avoid conflict is it ok to use
say 999 as mem bank number, ie, PB won't go creating 998 other
entries in a table somewhere? I expect PB is using a linked list
to store -to- pairings but thought I'd
ask because I may end up using a very large mem bank number.
Fred is working now to remove memory bank numbers, or at least make them optional. I don't think PureBasic would use the memory banks internally, as they should be for our use.

One other thing you might want to try, is that if you are not doing something where the pointer to your memory bank is going to change memory location, i.e. if you are using an array to store bank pointers but you will not sort them, you could make the address of your pointer as the memory bank number, i.e.

Code: Select all

*some_memory = AllocateMemory(@*some_memory, size, flags)
Depending on your needs for the memory banks, you might then never have any conflicts.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + all updates, PB3.51, Ed3.53)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

If you want to avoid any Conflict, you can use GlobalAlloc_(). You then only get a Memory Address, and no Bank Numbers are needed.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by dmoc.

Thanks both.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

no, PB allocates bank contigously, which means, than 1000 banks allocates 1000 slots. For memory bank, it probably not needed and I could remove it soon.

Fred - AlphaSND
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

"I could remove it soon" - for the next release? It's beginning to cause me a problem because I need to allocate using arbitrary bank numbers but I still want to avoid a Windows specific solution.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

dmoc wrote:"I could remove it soon" - for the next release? It's beginning to cause me a problem because I need to allocate using arbitrary bank numbers but I still want to avoid a Windows specific solution.
You could use my RawMemory library if you are willing to write the Linux version of the code ;)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Tinman, thanks for your library and I will take a look sometime (re Linux) but at the mo I'm trying to avoid any more distractions. I already have enough working around quite a few PB issues :?
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Related question: gadget numbers have to be unique but does this include window numbers and mem bank numbers? Eg, if I want banks # 0 to 100 does that mean gadget/ window numbers must >100?
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post by tinman »

dmoc wrote:Related question: gadget numbers have to be unique but does this include window numbers and mem bank numbers? Eg, if I want banks # 0 to 100 does that mean gadget/ window numbers must >100?
No, every library has it's own set of numbers.
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Tinman, thanks for the info.
Post Reply