fixing AutoPointer on an array of structs with custom memory releasing issue