// Copyright (c) the JPEG XL Project Authors. All rights reserved. // // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.
// To avoid RFOs, match L2 fill size (pairs of lines); 2 x cache line size. static constexpr size_t kAlignment = 2 * 64;
static_assert((kAlignment & (kAlignment - 1)) == 0, "kAlignment must be a power of 2");
// Minimum multiple for which cache set conflicts and/or loads blocked by // preceding stores can occur. static constexpr size_t kNumAlignmentGroups = 16; static constexpr size_t kAlias = kNumAlignmentGroups * kAlignment;
static_assert((kNumAlignmentGroups & (kNumAlignmentGroups - 1)) == 0, "kNumAlignmentGroups must be a power of 2");
} // namespace memory_manager_internal
// Initializes the memory manager instance with the passed one. The // MemoryManager passed in |memory_manager| may be NULL or contain NULL // functions which will be initialized with the default ones. If either alloc // or free are NULL, then both must be NULL, otherwise this function returns an // error.
Status MemoryManagerInit(JxlMemoryManager* self, const JxlMemoryManager* memory_manager);
// Helper class to be used as a deleter in a unique_ptr<T> call. class MemoryManagerDeleteHelper { public: explicit MemoryManagerDeleteHelper(const JxlMemoryManager* memory_manager)
: memory_manager_(memory_manager) {}
// Delete and free the passed pointer using the memory_manager. template <typename T> voidoperator()(T* address) const { if (!address) { return;
}
address->~T(); return memory_manager_->free(memory_manager_->opaque, address);
}
// TODO(eustas): we can offer "actually accessible" size; it is 0-2KiB bigger // than requested size, due to generous alignment; // might be useful for resizeable containers (e.g. PaddedBytes)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.