malloc is weakly pure, because it returns mutable pointer. The difference is when you call it from strongly pure function, then it doesn't matter, how many times malloc was called.