adl_flhGetUsedSize() for a single Object ID


Has anyone else needed to get the size of a single Object ID in flash?

adl_flhGetUsedSize() takes a range of object IDs - and the range is INCLUSIVE - so the size value returned is the sum of all object sizes including the beginning and end range IDs.

I need to get the size of a single ID (i.e. I’m storing variable length text strings as part of a configuration routine). I had thought about getting the size from a range of three IDs containing the ID I need, and then the size of a range of the two IDs I don’t need and subtracting this from the first. This is messy, and there are edge conditions to take care of…

I have tried calling adl_flhGetUsedSize() with the same ID for the beginning and the end value - but get an error (as is expected from reading the API doco).

Any one else had this issue? If so, some hints on how you did it would be appreciated.

Thanks, Dave

I did have the same problem years ago. I don’t remember whether adl_flhGetUsedSize() didn’t exist back then, but I simply solved it by storing the length of an object ID into the next object ID. like:
obj ID=1: myData
obj ID=2:myDataSizeInBytes

You could also store the length into the first 2 bytes of the object, since don’t have to read the whole object at once.

Best regards,



Ta, thanks for that. Much appreciated.

I must have been having an off day though - when implementing your suggestion, I re-read the API doco, and found that adl_flhExist() (which I was already using to test if the ID was valid), returns the size (in bytes) of the requested ID if the Handle has been subscribed and the ID is valid.


So I can do an adl_flhExist() to get the size of memory used by the ID, use this value (if it’s valid) to allocate RAM and then read the ID using adl_flhRead().

Thanks Again.

ciao, Dave