I am making a simple byte buffer that stores its data in a char array acquired with new and I was just wondering if the memcpy and memmove functions would give me anything weird if used on memory acquired with new or is there anything you would recommend doing instead?
Share
No, they are perfectly fine.
newandmalloc()are just two different ways in you can aquire memory on the heap (actually they are quite the same, becausenewusesmalloc()under the hood in most implementations). As soon as you have a validchar*variable in your hand (allocated bynew,malloc()or on the stack) it is just a pointer to memory, hencememcpy()and other functions from this family will work as expected.