Path: blob/main/contrib/llvm-project/lld/Common/Memory.cpp
34879 views
//===- Memory.cpp ---------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lld/Common/Memory.h"9#include "lld/Common/CommonLinkerContext.h"1011using namespace llvm;12using namespace lld;1314SpecificAllocBase *15lld::SpecificAllocBase::getOrCreate(void *tag, size_t size, size_t align,16SpecificAllocBase *(&creator)(void *)) {17auto &instances = context().instances;18auto &instance = instances[tag];19if (instance == nullptr) {20void *storage = context().bAlloc.Allocate(size, align);21instance = creator(storage);22}23return instance;24}252627