note this might segfault if p is NULL