]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/stdalgo.h
Add a new runtime directory and move the pid file to it.
[user/henk/code/inspircd.git] / include / stdalgo.h
index 683b2655bc9eb111bf9fb8c81160a3d3cc2cfbad..c0baa9dd8ef843de3050dfea8c1f8d435326032f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
- *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018, 2020 Sadie Powell <sadie@witchery.services>
  *   Copyright (C) 2014, 2016, 2018 Attila Molnar <attilamolnar@hush.com>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
@@ -182,6 +182,17 @@ namespace stdalgo
                std::for_each(cont.begin(), cont.end(), defaultdeleter<T>());
        }
 
+       /** Deletes a object and zeroes the memory location that pointed to it.
+        * @param pr A reference to the pointer that contains the object to delete.
+        */
+       template<typename T>
+       void delete_zero(T*& pr)
+       {
+               T* p = pr;
+               pr = NULL;
+               delete p;
+       }
+
        /**
         * Remove an element from a container
         * @param cont Container to remove the element from