Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BLI_alloca.h « blenlib « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6529fe534fdab7d53553ef96fc4bea269d36f684 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* SPDX-License-Identifier: GPL-2.0-or-later */

#pragma once

/** \file
 * \ingroup bli
 *
 * Defines alloca and utility macro BLI_array_alloca
 */

/* BLI_array_alloca / alloca */

#include <stdlib.h>

#if defined(__GNUC__) || defined(__clang__)
#  if defined(__cplusplus) && (__cplusplus > 199711L)
#    define BLI_array_alloca(arr, realsize) (decltype(arr))alloca(sizeof(*arr) * (realsize))
#  else
#    define BLI_array_alloca(arr, realsize) (typeof(arr))alloca(sizeof(*arr) * (realsize))
#  endif
#else
#  define BLI_array_alloca(arr, realsize) alloca(sizeof(*arr) * (realsize))
#endif