No, it is not thread safe. Consider two threads with a pointer to myMemory, if one thread reallocates myMemory, how does the other thread know that it's myMemory pointer is now invalid (realloc may move the memory block).
You may want to consider having a fixed-location structure like:
struct memory {
pthread_mutex_t _mutex; // Mutex for thread safe operations
size_t _size; // Memory size
void *memory_ptr; // pointer to memory
};
then allocate, reallocate and access your memory with functions like (pseudo-code):
alloc_memory()
malloc struct memory
memory_ptr= malloc memory reqd
fill in memory struct
reallocMemory( struct memory *, new_size )
obtain mutex
reallocate memory pointed to by memory_ptr
release mutex
void * start_access_memory( struct memory *)
obtain mutex
return memory_ptr
end_access_memory( struct memory *)
release mutex
This way each thread may have a persistent pointer to a memory structure and its mutex.