StackAlloc.h#
Fully qualified name: carb/StackAlloc.h
File members: carb/StackAlloc.h
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
//
// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
// property and proprietary rights in and to this material, related
// documentation and any modifications thereto. Any use, reproduction,
// disclosure or distribution of this material and related documentation
// without an express license agreement from NVIDIA CORPORATION or
// its affiliates is strictly prohibited.
#pragma once
#include "AlignSize.h"
#if defined DOXYGEN_BUILD
# define CARB_ALLOCA(size)
#elif CARB_PLATFORM_WINDOWS
# include <malloc.h>
# define CARB_ALLOCA(size) _alloca(size)
#elif CARB_PLATFORM_LINUX
# include <alloca.h>
# define CARB_ALLOCA(size) alloca(size)
#else
CARB_UNSUPPORTED_PLATFORM();
#endif
#define CARB_STACK_ALLOC(T, number) \
carb::align<T>((((number) != 0) ? (T*)CARB_ALLOCA((number) * sizeof(T) + alignof(T)) : nullptr), alignof(T))