data_abstract_structure.cpp 801 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "data/data_abstract_structure.h"
  8. #include "base/never_freed_pointer.h"
  9. namespace Data {
  10. namespace {
  11. using DataStructures = OrderedSet<AbstractStructure**>;
  12. base::NeverFreedPointer<DataStructures> structures;
  13. } // namespace
  14. namespace internal {
  15. void registerAbstractStructure(AbstractStructure **p) {
  16. structures.createIfNull();
  17. structures->insert(p);
  18. }
  19. } // namespace internal
  20. void clearGlobalStructures() {
  21. if (!structures) return;
  22. for (auto &p : *structures) {
  23. delete (*p);
  24. *p = nullptr;
  25. }
  26. structures.clear();
  27. }
  28. } // namespace Data