1

Intel Document only describes ptr passed in should point the space allocated from ippsMalloc. It does not say anything what happened if we pass a null pointer in it.

void ippsFree(void* ptr);

ptr Pointer to a memory block to be freed. The memory block pointed to with ptr is allocated by the function ippsMalloc.

Is it safe like free/delete accept null pointer? or is it undefined?

Chen OT
  • 3,486
  • 2
  • 24
  • 46
  • 2
    Well, you'd ultimately have to ask intel about that, but it would be IMHO quite brain-dead to provide alternative `malloc()`/`free()` implementations with different semantics from the standard library ones **without** explicitly documenting this. So my *guess* is it's safe. –  Sep 24 '15 at 09:21
  • Actually I met a problem when I try to register on Intel Developer Zone for posting on forum, so I post here. Maybe someone may have the same question like me. I am afraid there is additional processing in ippsFree that assumes the ptr is non-null. – Chen OT Sep 24 '15 at 09:31
  • 1
    This [code example](https://software.intel.com/en-us/node/504353) on the Intel site uses `ippsFree` to free two pointers when the allocation of at least one of them nas failed and is `NULL`. So according to this example, it is safe to pass `NULL`. – M Oehm Sep 24 '15 at 09:33
  • If the official example demonstrates how to allocate/free the memory like it, it may be safe to pass null pointer in. Thanks! – Chen OT Sep 24 '15 at 09:44
  • Why not just try it out in a noddy program. If it misbehaves, then you know it is not safe. – cup Sep 24 '15 at 11:28
  • 1
    Fine on my platform does not mean ok on other platform. Maybe it is just lucky not crash on my testing case. – Chen OT Sep 25 '15 at 00:44

1 Answers1

2

Looking at the dis-assembly of ippsFree function, the functions tests the argument (pointer) upon entry. It is safe to use NULL pointer.

agmonm
  • 21
  • 3