Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / position of a Memblock in memory

Author
Message
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Nov 2014 16:42
can you change the position in memory at which a Memblock resides (using conventional dbpro commands)? I'm thinking particularly of a blank memblock?

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Nov 2014 16:45
You can create a blank memblock, but I don't think you have any control over which memory address it uses. Changing that yourself is potentially dangerous.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Nov 2014 16:49
Dangerous, yes, but perhaps necessary for a plugin I'm working on.

Hey ho - back to the drawing board.

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Nov 2014 16:52
Could try something with pointers. And I bet one of IanM's libraries would have something that can help.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 26th Nov 2014 17:04
@ Phaelax,

Yeah was looking at Map Memory to Bank in IanM's plugin - of course you would then need that plugin for my plugin to work....

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...
Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 26th Nov 2014 17:07
He might give you the source for those commands if you ask, so you can incorporate them directly into your plugin.


"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Nov 2014 18:59
It seems that Lee Bamber already figured out this matter when he created the Get Memblock Ptr command.



I cannot say that I am 100% sure what your goal is; but rest assured if the users of your plugin need to supply memory addresses of memblocks, they can do so with the native command Get Memblock Ptr.

In summary it would not be a bad idea to take Phaelax's advice and ask Ian for tips on memblock control in your plugin, that would prove more useful in the long term.

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 27th Nov 2014 00:12 Edited at: 27th Nov 2014 00:18
As I suggested in your other post about this it is possible and perfectly safe. Here's a small DBPro example showing how you can manually delete a memblock, swap two memblocks and resize a memblock.
It uses the WINAPI HeapAllocate and HeapFree functions because DBPro's built-in MAKE MEMORY and DELETE MEMORY functions are restricted to only work with each other, ie. you can't use DELETE MEMORY on a pointer that you haven't allocated using MAKE MEMORY. In another language you can just replace these calls with the standard allocation / releasing functions such as malloc() and free() in C.



Duffer
23
Years of Service
User Offline
Joined: 9th Feb 2003
Location: chair
Posted: 29th Nov 2014 12:13
@ Chris Tate, Phaelax & Rudulpho,

Thanks all. Tonnes of info there to digest and consider. I am almost sorted with my plugin, I hope...

a long time dabbler with DBC and DBPro with no actual talent but lots of enthusiasm...

Login to post a reply

Server time is: 2026-07-05 22:37:38
Your offset time is: 2026-07-05 22:37:38