Page 2 of 2

Posted: Tue Aug 12, 2008 2:21 am
by ProphetOfDoom
er yeah I am still quite new to PureBASIC and I didn't really expect to have to do esoteric stuff like writing a string class just to get program working properly. I wouldn't even know where to start. I did a bit of C++ once but that was about 7 years ago and I've probably forgotten most of it. And wolf thanks for trying to help but your post was a little bit... terse and I didn't get it. Anyway this is really a feature request not a workaround request (altho I am grateful for people's help).

Posted: Tue Aug 12, 2008 3:20 am
by Kaeru Gaman
since you did not explain what you used and how you programmed it,
I think it would be really difficult to read a real feature request from it...

you said you allocated memory for a selfmade "object"... fine.
you say nothing how your "object" was constructed.

if I had to guess, I would think you built a Structure for your "object".
if so, why didn't you use a LinkedList for your objects, or an Array?
as far as I know, when deleting an LL-Element containing dynamic strings,
they are deleted properly including the connected string.

if you build an "object" within some manually Allocated Memory,
you should be aware that dynamic strings in PB are not located within Structs, but only their pointers are.
when you work with pointers and memory, you have to take care of your content by yourself.
how should a FreeMemory command know, that some of the bytes contained within represent a pointer?
you have to follow that pointer first and delete the string manually,
before you Free the Memory of the "object".

as I said before, if you use LinkedLists with structured elements,
the strings from the pointers contained by those elements
should be freed correctly when deleting the elements.

another possibility to avoid this problem is, to use strings of fixed length.
those will be directly located within the structure and thus be properly deleted when freeing the memory.

Posted: Tue Aug 12, 2008 3:59 am
by ProphetOfDoom
Hi,

I never said that FreeMemory should magically understand that an object contains strings. That was the whole point of the topic. I suggested adding a Delete operator which *would* understand that. Like BlitzBASIC has. I couldn't use fixed strings because er, I needed unlimited length strings. I already said that. I suppose I could have used PB's own linked lists but I just decided not to.

And this:
you should be aware that dynamic strings in PB are not located within Structs, but only their pointers are.
when you work with pointers and memory, you have to take care of your content by yourself.
I know all that. I tried freeing the strings with FreeMemory but it crashes the program (judging by the post someone linked to earlier, that's because the PB strings and the other dynamic memories are in different heaps).

I think I explained pretty well how my code worked and everything. Just dynamically allocated structures with strings in. What more does anyone need to know?

I made a perfectly legitimate feature request so just/// let it be

Posted: Tue Aug 12, 2008 4:08 am
by Little John
Hroudtwolf wrote:Why, you don't accost myself directly? ;-)
??
Hroudtwolf wrote:Its a fact, that I've expected (or interpreted) more knowledge by the threadfounder about this subject matter.
This is the reason of my "cryptic" post.
There was no basis at all for this assumption.
Hroudtwolf wrote:PS: Should I pray 100x "Our Father..." for my bad mistake?
I would be sufficient not to "accost" other people because of your mistake.

ProphetOfDoom wrote:er yeah I am still quite new to PureBASIC and I didn't really expect to have to do esoteric stuff like writing a string class just to get program working properly.
I hope in the meantime it has become clear that you don't have to do so, of course!
ProphetOfDoom wrote:I made a perfectly legitimate feature request so just/// let it be
I agree.

Regards, Little John

Posted: Tue Aug 12, 2008 4:27 am
by ProphetOfDoom
:D

Posted: Tue Aug 12, 2008 11:28 am
by Hroudtwolf
Little John wrote:There was no basis at all for this assumption.
To ascertain this, should be outside your province. ;-)

Posted: Tue Aug 12, 2008 11:56 am
by Little John
You don't know anything about my province.

Regards, Little John

Posted: Tue Aug 12, 2008 12:04 pm
by Hroudtwolf
^____^

Posted: Tue Aug 12, 2008 1:48 pm
by Kaeru Gaman
I think I explained pretty well how my code worked and everything. Just dynamically allocated structures with strings in. What more does anyone need to know?
"dynamically allocated structures" was what I guessed, there not a single word explaining it in yout first post.
I know all that.
then you should be able to write your own object destructor.
ProphetOfDoom wrote:I made a perfectly legitimate feature request
I don't think so.

you are not only asking for a kill routine, you are asking for a completely new object handling system.


but awright, we are spamming a feature-request-thread.
some Mod should delete the crap and you should wait for an answer from the team...