Page 1 of 1

New and Delete

Posted: Wed Jun 25, 2003 4:59 pm
by freedimension
For the Structures, I would appreciate a New- and a Delete-Instruction for easily allocating and freeing Memory (without the need for a variable).
The New-Command should return a pointer with which I then can do all the interesting stuff, like my very own dynamic List- and Tree-Structures.

I really really miss this and it would simplify programming in PB so much, that's for me.

Thx
Mirko

Re: New and Delete

Posted: Wed Jun 25, 2003 5:39 pm
by tinman
freedimension wrote:The New-Command should return a pointer with which I then can do all the interesting stuff, like my very own dynamic List- and Tree-Structures.
like:

*foo.mytype = AllocateMemory(Sizeof(mytype), 0)
FreeMemory(*foo)

Unfortunately, the memory library has not yet been updated to not require bank numbers. Or do you want the calling of constructor/destructor type procedures too? You could try my RawMemory library which lets you do this, but a Linux version does not exist for now (and I think the parameters are slightly different). http://www.reelmediaproductions.com/pb or my website.

Posted: Wed Jun 25, 2003 11:02 pm
by freedimension
Yeah, but not so "complicated" (I know it's not that complicated, let's say inconvenient). I mean, other languages do have "new" and "delete", so it has to be possible to implement it without the extra size Parameter.