All you need to do is read the location that pointer points to as an atomic operation. So allocating a 50kb string would work in the same way as long as you could store it in a specific processes memory.
PX a=(0x00010001) //which points to 5
P0 x0=a=(0x00010001) //which points to 5
P1 y0=a
P1 pointer y1=0
P1 y1 = malloc(sizeof(int))
P2 x1=a=(0x00010001) //which points to 5
P1 *y = *y0 + 1 //aka 6
p3 x2=a=(0x00010001) //which points to 5
P1 a=y //you could do a lock to verify that a == (0x00010001) but if you don't care about dirty writes then then you can also do this as an atomic operation.
p3 x3=a=(0x00030001)//which points to 6
And once x0,x1,x2 stop pointing to (0x00010001) you can free that memory. The assumption is xN and yN is a process specific local variable preferably a register.