Is there a short-hand for specifying size of objects pointed to (i.e. char*, float*)?
ags
Posts: 386
For the purpose of only using memory when needed (as opposed to global VAR/DAT symbols), I use a method I'd describe as pseudo-stack creation. Whenever I want to return a value from a method that is larger (in size) than one long, I implement the method with a parameter that is a pointer to a location where the return value will be placed. This is not optimal, because to be reasonably safe I should also use a parameter that specifies the maximum size of that location, and have the (called) function implement checks to be sure that the maximum size is not exceeded. I presume this is a frequent issue, and I don't have a better solution (but I'm open to learning).
What I would like to know is if there is a way to avoid all the explicit size specifications when writing to the calling method's buffer. A typical pattern is that I am writing byte elements. Every time I do, I have to use the byte[baseAddress][offset] syntax (or byte[baseAddress+offset]). I find this ugly, too much typing, and error prone. Is there another pattern that can be used?
What I would like to know is if there is a way to avoid all the explicit size specifications when writing to the calling method's buffer. A typical pattern is that I am writing byte elements. Every time I do, I have to use the byte[baseAddress][offset] syntax (or byte[baseAddress+offset]). I find this ugly, too much typing, and error prone. Is there another pattern that can be used?
Comments
Also, if I want to allow use of different size objects, and arrays, I would have to reserve (in VAR/DAT) enough memory to hold the maximum number of all objects stored at any one time. I suppose I could have multiple objects. But now the issue seems to be how to dynamically allocate hum RAM? Is this possible?
If there is an implementation that you could point me to that would be helpful.
Thanks.
As for your original question, AFAIK, there are no other short hand commands other than what's found in the Propeller Manual.
PRI CalledFunction(byte[memPtr])
Unfortunately, I haven't been able to find any creative way to accomplish that.