// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.
// A runtime sized aligned allocation can be created: // // float* my_array = static_cast<float*>(AlignedAlloc(size, alignment)); // // // ... later, to release the memory: // AlignedFree(my_array); // // Or using unique_ptr: // // std::unique_ptr<float, AlignedFreeDeleter> my_array( // static_cast<float*>(AlignedAlloc(size, alignment)));
namespace base {
// This can be replaced with std::aligned_alloc when we have C++17. // Caveat: std::aligned_alloc requires the size parameter be an integral // multiple of alignment.
BASE_EXPORT void* AlignedAlloc(size_t size, size_t alignment);
// Deleter for use with unique_ptr. E.g., use as // std::unique_ptr<Foo, base::AlignedFreeDeleter> foo; struct AlignedFreeDeleter { inlinevoidoperator()(void* ptr) const {
AlignedFree(ptr);
}
};
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.