I have made an array of pointers to places in memory I would like to write to while treating them as a continuous block. But I cannot find the syntax for doing this as all examples of dereferencing has the pointer to the value being copied and not the one being overwritten.
To ensure you always work with a valid pointer you should take care of the following:
Always call the code which references the pointer and not do this only once(!) Doing it continuously ensures correct working during a warm download after a code change, besides the overhead is minimal compared to a crashing application ;-)
Plus always test the validity of the pointer before dereferencing it, even if you are sure that it is initialised properly.
An escape is to rewrite your code using References, they are "equal" to pointers but are typesafe.
Hope this helps you
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have made an array of pointers to places in memory I would like to write to while treating them as a continuous block. But I cannot find the syntax for doing this as all examples of dereferencing has the pointer to the value being copied and not the one being overwritten.
This triggers a runtime error at the assignment:
Last edit: jsaxin 2020-10-13
I have found that I never actually initiated the pointer. Please delete this thread.
Some tips after seeing your code snippet:
To ensure you always work with a valid pointer you should take care of the following:
Always call the code which references the pointer and not do this only once(!) Doing it continuously ensures correct working during a warm download after a code change, besides the overhead is minimal compared to a crashing application ;-)
Plus always test the validity of the pointer before dereferencing it, even if you are sure that it is initialised properly.
An escape is to rewrite your code using References, they are "equal" to pointers but are typesafe.
Hope this helps you
Thank you. I will look into references.
Alas, it turns out references cannot be put into arrays.
Ah, I never considered that. But pointers should do fine if you check them <> 0 before trying to dereference them.