void ** equivalent to void * return?

c, c++

Solution

Any kind of pointer can be implicitly converted to a `void *`, including a pointer to a `void *`, aka `void **`.

Problem

``` void * alligned_malloc(size_t bytes , uint16_t allign) { uint16_t offset = allign - 1 + sizeof(void*); void* p1 = malloc(offset + bytes); void**p2 = (void**)(((size_t)p1+offset) & ~(allign - 1)); p2[-1] = p1; return p2; // Why is this correct ? should not the return be p2[0] as it is returning void** } ``` Please help me understand this modified malloc how is void** equivalent to void * return in this code ?

Original source