Post Reply 
[HP48] Memory Management
10-24-2014, 04:48 PM
Post: #3
RE: [HP48] Memory Management
As David said, it's not directly possible, but you could hack your way around it.
A directory is not too different from a list internally, so you could (in theory) do the following:
Let's say you have variables A B and C in a directory:

In memory this looks like (more or less, there's other things especially at the beginning of a directory):
<DIR> A <value-of-A> B <value-of-B> C <value-of-C> <END>

If you want to destructively stretch A, you could create a variable with a string, libdata, or whatever, with enough extra space as needed (let's call it EXTRA), and you store it in the directory. Now you get:

<DIR> EXTRA <string> A <value-of-A> B <value-of-B> C <value-of-C> <END>

Now you could surgically change the size field of the string/libdata object to "engulf" the name A and the content of A. After that, the directory becomes:

<DIR> EXTRA <string + name A + value-of-A> B <value-of-B> C <value-of-C> <END>

Now it's up to you to properly stretch <value-of-A> within the allocated space.

If the variable to stretch is not the first of the directory, you'd have to sort the variables, which implies moving the large data. So this technique will not give you any performance advantage, since you'll end up moving the data anyway, but it does not need to make a second copy of the data to patch it, allowing your routine to work with less memory.

Do I need to tell you that if you miscalculate the size to "engulf" even by one nibble you'll corrupt your directories and likely loose all your precious and large data? You probably guessed that already.

Claudio
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[HP48] Memory Management - Bruno - 10-24-2014, 12:34 PM
RE: [HP48] Memory Management - Claudio L. - 10-24-2014 04:48 PM
RE: [HP48] Memory Management - Bruno - 10-27-2014, 10:12 AM
RE: [HP48] Memory Management - Claudio L. - 10-27-2014, 12:04 PM
RE: [HP48] Memory Management - Paul Dale - 10-27-2014, 10:18 AM
RE: [HP48] Memory Management - Bruno - 10-27-2014, 01:15 PM
RE: [HP48] Memory Management - Han - 10-27-2014, 10:08 PM
RE: [HP48] Memory Management - Bruno - 10-29-2014, 10:15 PM



User(s) browsing this thread: 1 Guest(s)