I have code that moves bytes in a buffer using memmove(). The buffer is accessed by multiple threads. I get very strange behavior; sometimes a buffer is not what it should be, and I thought that if memmove()and / and malloc()are thread safe. I am working on iOS (in case it is platform dependent).
memmove()
malloc()
An implementation that provides threads mallocwill usually be thread safe (i.e., it will take steps to ensure that the heap will not be corrupted, even if it mallocis called from multiple threads). The exact way this will happen varies: some use one heap and internal synchronization to prevent corruption. Others will use multiple heaps, so different threads can simultaneously allocate memory without collisions.
malloc
memmove it will usually be the same as if you were making assignments in your own code - if you use shared access to streams in a buffer, it is your responsibility to synchronize access to this data.
memmove
(NSLock) . Apple .
Malloc . , C , , . iOS.
Memmove ( ) , .
C , . , , , , C, , . , iOS, POSIX Windows , malloc , , , 90-, .
, C1x , , malloc .
No, since the standard C library does not have the concept of threads, the functions that it defines cannot exist.