template <typename T>
void SafeDelete(T *& p) { delete p; p = NULL; }