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.

DLL Talk / Matrix1Array - how do you expand an array?

Author
Message
Grismald
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: France
Posted: 29th Jul 2006 09:57
I want to do something like that:


I know this code doesn't work, but is there some way to
achieve this?
thanks in advance

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Jul 2006 23:13
Yes, you have to unlink from the original array first, pass back the new pointer you get from expanding the array, and then relink back to the original array.



For free Plug-ins and source code http://www.matrix1.demon.co.uk
Grismald
21
Years of Service
User Offline
Joined: 4th Mar 2003
Location: France
Posted: 4th Aug 2006 20:42 Edited at: 4th Aug 2006 21:23
thanks, but actually i would like to have all the code into one function, like this:




This means i'd need 2 new functions ,unlink arrayptr and
link arrayptr which would accept an array pointer as argument instead of the array name.
BTW, in the dll readme, you mention a UNLINK ARRAYPTR function
Quote: "UNLINK ARRAYPTR - Unlinks an array from its pointer
UNLINK ARRAYPTR a()"

but it doesn't seem to exist.

EDIT: The goal is to create a function similar to ARRAY INSERT AT BOTTOM which would accept an array pointer instead of an array name.

IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Aug 2006 13:20
It's not technically possible within DBPro code, and here's why - Increasing the size of an array causes DBPro to allocate new memory to build the array into, the data to be moved across, and then the old memory freed. The problem is that the original array variable will still point to the freed memory. That will cause future array or string allocations to be corrupted if you use that array, the memory heap to be corrupted, and even crashes to occur.

It might be possible to do within the plugin, but I'm not sure of that and I'd have to think about it for a while.

UNLINK ARRAYPTR = UNLINK ARRAY POINTER
... it's just a typo.

Login to post a reply

Server time is: 2024-11-22 12:30:23
Your offset time is: 2024-11-22 12:30:23