diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-05-05 18:27:50 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-05-09 18:27:59 +0200 |
commit | 5bb5d61cdd76f816c0af3cda5b610f5c34f41023 (patch) | |
tree | df2778073b457749c603c21441f4c58bd3f62975 | |
parent | 2c52f656bd95f1809ac1f75cfd55cf0563301279 (diff) | |
download | android-node-v8-5bb5d61cdd76f816c0af3cda5b610f5c34f41023.tar.gz android-node-v8-5bb5d61cdd76f816c0af3cda5b610f5c34f41023.tar.bz2 android-node-v8-5bb5d61cdd76f816c0af3cda5b610f5c34f41023.zip |
src: remove unused freelist.h header
Always easy enough to re-introduce if we do need it.
PR-URL: https://github.com/nodejs/node/pull/20544
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matheus Marchini <matheus@sthima.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
-rw-r--r-- | src/freelist.h | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/src/freelist.h b/src/freelist.h deleted file mode 100644 index 7dff56a35d..0000000000 --- a/src/freelist.h +++ /dev/null @@ -1,92 +0,0 @@ -#ifndef SRC_FREELIST_H_ -#define SRC_FREELIST_H_ - -#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS - -#include "util.h" - -namespace node { - -struct DefaultFreelistTraits; - -template <typename T, - size_t kMaximumLength, - typename FreelistTraits = DefaultFreelistTraits> -class Freelist { - public: - typedef struct list_item { - T* item = nullptr; - list_item* next = nullptr; - } list_item; - - Freelist() {} - ~Freelist() { - while (head_ != nullptr) { - list_item* item = head_; - head_ = item->next; - FreelistTraits::Free(item->item); - free(item); - } - } - - void push(T* item) { - if (size_ > kMaximumLength) { - FreelistTraits::Free(item); - } else { - size_++; - FreelistTraits::Reset(item); - list_item* li = Calloc<list_item>(1); - li->item = item; - if (head_ == nullptr) { - head_ = li; - tail_ = li; - } else { - tail_->next = li; - tail_ = li; - } - } - } - - T* pop() { - if (head_ != nullptr) { - size_--; - list_item* cur = head_; - T* item = cur->item; - head_ = cur->next; - free(cur); - return item; - } else { - return FreelistTraits::template Alloc<T>(); - } - } - - private: - size_t size_ = 0; - list_item* head_ = nullptr; - list_item* tail_ = nullptr; -}; - -struct DefaultFreelistTraits { - template <typename T> - static T* Alloc() { - return ::new (Malloc<T>(1)) T(); - } - - template <typename T> - static void Free(T* item) { - item->~T(); - free(item); - } - - template <typename T> - static void Reset(T* item) { - item->~T(); - ::new (item) T(); - } -}; - -} // namespace node - -#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS - -#endif // SRC_FREELIST_H_ |