It has undefined behaviour, since pointer arithmetic is only defined within an array.
In practice, on a machine that represents pointers by a numerical address, and with sufficiently large integers, and a null pointer represented by address zero, it will convert a byte address into a word address. That is, it gives the number of int
-sized lumps of memory between the null pointer's address and the address p
.
Also there was a comment that this is a pure and re-entrant function.
"Pure" means that it has no side-effects, and the result only depends on its inputs. "re-entrant" means that it's safe to call while it's already in progress (for example, from an interrupt handler) - it has no internal static data.