The documentation of OSData
says that "...You can add bytes to them and overwrite portions of the byte array.". I can see a method to append bytes, but I don't understand how I am able to overwrite a portion of the buffer.
Another option would be to use IONewZero
to allocate a number of elements of the type I need. I my case I just need this for int
s.
Example:
T* dataBuffer = IONewZero(T, SIZE);
And then deallocate with:
IOSafeDeleteNULL(dataBuffer_, T, SIZE);
What are the advantages of using an OSData
object compared to the solution with IONewZero
/ IOSafeDeleteNULL
?