Refactor: Convert remainder of blenlib to C++
A few headers like BLI_math_constants.h and BLI_utildefines.h keep working for C code, for remaining makesdna and userdef defaults code in C. Pull Request: https://projects.blender.org/blender/blender/pulls/134406
This commit is contained in:
@@ -5,15 +5,13 @@
|
||||
/* Preferences Data File 'U_default'. */
|
||||
|
||||
/* For constants. */
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_constants.h"
|
||||
|
||||
#include "DNA_anim_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
#include "DNA_space_types.h"
|
||||
#include "DNA_userdef_types.h"
|
||||
|
||||
#include "BLI_math_rotation.h"
|
||||
|
||||
#include "BKE_blender_version.h"
|
||||
|
||||
#include "GPU_platform_backend_enum.h"
|
||||
|
||||
@@ -12,16 +12,8 @@
|
||||
|
||||
/* BLI_array_alloca / alloca */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
#include <type_traits> /* IWYU pragma: keep */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
# include <type_traits>
|
||||
# define BLI_array_alloca(arr, realsize) \
|
||||
(std::remove_reference_t<decltype(arr)>)alloca(sizeof(*arr) * (realsize))
|
||||
#else
|
||||
# if defined(__GNUC__) || defined(__clang__)
|
||||
# define BLI_array_alloca(arr, realsize) (typeof(arr))alloca(sizeof(*arr) * (realsize))
|
||||
# else
|
||||
# define BLI_array_alloca(arr, realsize) alloca(sizeof(*arr) * (realsize))
|
||||
# endif
|
||||
#endif
|
||||
#define BLI_array_alloca(arr, realsize) \
|
||||
(std::remove_reference_t<decltype(arr)>)alloca(sizeof(*arr) * (realsize))
|
||||
|
||||
@@ -9,12 +9,7 @@
|
||||
* \brief A general argument parsing module.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct bArgs;
|
||||
typedef struct bArgs bArgs;
|
||||
|
||||
#include <stdarg.h> /* For `va_list`. */
|
||||
#include <stdbool.h>
|
||||
@@ -26,12 +21,12 @@ typedef struct bArgs bArgs;
|
||||
* - 0 is normal value,
|
||||
* - -1 stops parsing arguments, other negative indicates skip
|
||||
*/
|
||||
typedef int (*BA_ArgCallback)(int argc, const char **argv, void *data);
|
||||
using BA_ArgCallback = int (*)(int argc, const char **argv, void *data);
|
||||
|
||||
struct bArgs *BLI_args_create(int argc, const char **argv);
|
||||
void BLI_args_destroy(struct bArgs *ba);
|
||||
|
||||
typedef void (*bArgPrintFn)(void *user_data, const char *format, va_list args);
|
||||
using bArgPrintFn = void (*)(void *user_data, const char *format, va_list args);
|
||||
void BLI_args_printf(struct bArgs *ba, const char *format, ...);
|
||||
void BLI_args_print_fn_set(struct bArgs *ba,
|
||||
ATTR_PRINTF_FORMAT(2, 0) bArgPrintFn print_fn,
|
||||
@@ -71,7 +66,3 @@ void BLI_args_print_other_doc(struct bArgs *ba);
|
||||
bool BLI_args_has_other_doc(const struct bArgs *ba);
|
||||
|
||||
void BLI_args_print(const struct bArgs *ba);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BArrayState BArrayState;
|
||||
typedef struct BArrayStore BArrayStore;
|
||||
|
||||
@@ -100,7 +96,3 @@ void *BLI_array_store_state_data_get_alloc(BArrayState *state, size_t *r_data_le
|
||||
* \note Only for tests.
|
||||
*/
|
||||
bool BLI_array_store_is_valid(BArrayStore *bs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct BArrayStore;
|
||||
|
||||
struct BArrayStore_AtSize {
|
||||
@@ -32,7 +28,3 @@ void BLI_array_store_at_size_clear(struct BArrayStore_AtSize *bs_stride);
|
||||
void BLI_array_store_at_size_calc_memory_usage(const struct BArrayStore_AtSize *bs_stride,
|
||||
size_t *r_size_expanded,
|
||||
size_t *r_size_compacted);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#include "BLI_compiler_typecheck.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* In-place array reverse.
|
||||
*
|
||||
@@ -146,6 +142,3 @@ bool _bli_array_iter_spiral_square(const void *arr_v,
|
||||
void *user_data);
|
||||
#define BLI_array_iter_spiral_square(arr, arr_shape, center, test_fn, user_data) \
|
||||
_bli_array_iter_spiral_square(arr, arr_shape, sizeof(*(arr)), center, test_fn, user_data)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Utility functions. */
|
||||
|
||||
void _BLI_assert_print_pos(const char *file, int line, const char *function, const char *id);
|
||||
@@ -100,7 +96,3 @@ void _BLI_assert_unreachable_print(const char *file, int line, const char *funct
|
||||
BLI_assert_msg(0, "This line of code is marked to be unreachable."); \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,30 +11,24 @@
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_bitmap.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
||||
typedef struct BLI_AStarGNLink {
|
||||
struct BLI_AStarGNLink {
|
||||
int nodes[2];
|
||||
float cost;
|
||||
|
||||
void *custom_data;
|
||||
} BLI_AStarGNLink;
|
||||
};
|
||||
|
||||
typedef struct BLI_AStarGNode {
|
||||
struct BLI_AStarGNode {
|
||||
struct ListBase neighbor_links;
|
||||
|
||||
void *custom_data;
|
||||
} BLI_AStarGNode;
|
||||
};
|
||||
|
||||
typedef struct BLI_AStarSolution {
|
||||
struct BLI_AStarSolution {
|
||||
/* Final 'most useful' data. */
|
||||
/** Number of steps (i.e. walked links) in path
|
||||
* (nodes num, including start and end, is steps + 1). */
|
||||
@@ -52,16 +46,16 @@ typedef struct BLI_AStarSolution {
|
||||
int *g_steps;
|
||||
|
||||
struct MemArena *mem; /* Memory arena. */
|
||||
} BLI_AStarSolution;
|
||||
};
|
||||
|
||||
typedef struct BLI_AStarGraph {
|
||||
struct BLI_AStarGraph {
|
||||
int node_num;
|
||||
BLI_AStarGNode *nodes;
|
||||
|
||||
void *custom_data;
|
||||
|
||||
struct MemArena *mem; /* Memory arena. */
|
||||
} BLI_AStarGraph;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize a node in A* graph.
|
||||
@@ -119,12 +113,12 @@ void BLI_astar_solution_free(BLI_AStarSolution *as_solution);
|
||||
* \param node_idx_next: next node index.
|
||||
* \param node_idx_dst: destination node index.
|
||||
*/
|
||||
typedef float (*astar_f_cost)(BLI_AStarGraph *as_graph,
|
||||
BLI_AStarSolution *as_solution,
|
||||
BLI_AStarGNLink *link,
|
||||
int node_idx_curr,
|
||||
int node_idx_next,
|
||||
int node_idx_dst);
|
||||
using astar_f_cost = float (*)(BLI_AStarGraph *as_graph,
|
||||
BLI_AStarSolution *as_solution,
|
||||
BLI_AStarGNLink *link,
|
||||
int node_idx_curr,
|
||||
int node_idx_next,
|
||||
int node_idx_dst);
|
||||
|
||||
/**
|
||||
* Initialize an A* graph. Total number of nodes must be known.
|
||||
@@ -150,7 +144,3 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
|
||||
astar_f_cost f_cost_cb,
|
||||
BLI_AStarSolution *r_solution,
|
||||
int max_steps);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned int BLI_bitmap;
|
||||
|
||||
/* WARNING: the bitmap does not keep track of its own size or check
|
||||
@@ -148,7 +144,3 @@ void BLI_bitmap_or_all(BLI_bitmap *dst, const BLI_bitmap *src, size_t bits);
|
||||
* Returns -1 if all the bits are set.
|
||||
*/
|
||||
int BLI_bitmap_find_first_unset(const BLI_bitmap *bitmap, size_t bits);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct ListBase;
|
||||
|
||||
/* Box Packer */
|
||||
@@ -74,7 +70,3 @@ void BLI_box_pack_2d_fixedarea(struct ListBase *boxes,
|
||||
int width,
|
||||
int height,
|
||||
struct ListBase *packed);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BLI_Buffer {
|
||||
void *data;
|
||||
size_t elem_size;
|
||||
@@ -113,7 +109,3 @@ void _bli_buffer_free(BLI_Buffer *buffer);
|
||||
(void)0
|
||||
|
||||
#define BLI_buffer_field_free(name_) _bli_buffer_free(name_)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_struct_equality_utils.hh"
|
||||
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \file
|
||||
* \ingroup bli
|
||||
* \brief Set of utility functions and constants to work with consoles.
|
||||
@@ -20,7 +16,3 @@ extern "C" {
|
||||
|
||||
/* Marker which indicates that colored output is finished. */
|
||||
#define TRUECOLOR_ANSI_COLOR_FINISH "\x1b[0m"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Extract 2D convex hull.
|
||||
*
|
||||
@@ -34,7 +30,3 @@ int BLI_convexhull_2d(const float (*points)[2], int points_num, int r_points[/*p
|
||||
* \param points: Arbitrary 2D points.
|
||||
*/
|
||||
float BLI_convexhull_aabb_fit_points_2d(const float (*points)[2], int points_num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -33,16 +33,8 @@
|
||||
* \endcode
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct Dial Dial;
|
||||
|
||||
Dial *BLI_dial_init(const float start_position[2], float threshold);
|
||||
|
||||
float BLI_dial_angle(Dial *dial, const float current_position[2]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct DynStr;
|
||||
|
||||
/** The abstract DynStr type. */
|
||||
@@ -104,7 +100,3 @@ void BLI_dynstr_clear(DynStr *ds) ATTR_NONNULL();
|
||||
* \param ds: The DynStr to free.
|
||||
*/
|
||||
void BLI_dynstr_free(DynStr *ds) ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
float BLI_easing_back_ease_in(
|
||||
float time, float begin, float change, float duration, float overshoot);
|
||||
float BLI_easing_back_ease_out(
|
||||
@@ -49,7 +45,3 @@ float BLI_easing_quint_ease_in_out(float time, float begin, float change, float
|
||||
float BLI_easing_sine_ease_in(float time, float begin, float change, float duration);
|
||||
float BLI_easing_sine_ease_out(float time, float begin, float change, float duration);
|
||||
float BLI_easing_sine_ease_in_out(float time, float begin, float change, float duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* BLI_endian_switch_inline.h */
|
||||
|
||||
BLI_INLINE void BLI_endian_switch_int16(short *val) ATTR_NONNULL(1);
|
||||
@@ -39,10 +35,6 @@ void BLI_endian_switch_int64_array(int64_t *val, int size) ATTR_NONNULL(1);
|
||||
void BLI_endian_switch_uint64_array(uint64_t *val, int size) ATTR_NONNULL(1);
|
||||
void BLI_endian_switch_double_array(double *val, int size) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include "BLI_endian_switch_inline.h"
|
||||
|
||||
#endif /* __BLI_ENDIAN_SWITCH_H__ */
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* only include from header */
|
||||
#ifndef __BLI_ENDIAN_SWITCH_H__
|
||||
# error "this file isn't to be directly included"
|
||||
@@ -81,7 +77,3 @@ BLI_INLINE void BLI_endian_switch_double(double *val)
|
||||
{
|
||||
BLI_endian_switch_uint64((uint64_t *)val);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Opaque structure containing pre-parsed data for evaluation. */
|
||||
typedef struct ExprPyLike_Parsed ExprPyLike_Parsed;
|
||||
|
||||
@@ -59,7 +55,3 @@ eExprPyLike_EvalStatus BLI_expr_pylike_eval(struct ExprPyLike_Parsed *expr,
|
||||
const double *param_values,
|
||||
int param_values_len,
|
||||
double *r_result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
#include "BLI_fileops_types.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PATH_MAX
|
||||
# define PATH_MAX 4096
|
||||
#endif
|
||||
@@ -456,7 +452,3 @@ void BLI_get_short_name(char short_name[256], const char *filepath);
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __cplusplus
|
||||
# error This is a C++ header
|
||||
#endif
|
||||
|
||||
#include "BLI_fileops.h" // IWYU pragma: export
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
typedef unsigned int mode_t;
|
||||
#endif
|
||||
@@ -44,7 +40,3 @@ struct dirlink {
|
||||
struct dirlink *next, *prev;
|
||||
char *name;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
typedef int64_t off64_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct FileReader;
|
||||
|
||||
typedef int64_t (*FileReaderReadFn)(struct FileReader *reader, void *buffer, size_t size);
|
||||
@@ -61,7 +57,3 @@ FileReader *BLI_filereader_new_memory(const void *data, size_t len) ATTR_WARN_UN
|
||||
FileReader *BLI_filereader_new_zstd(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
/** Create #FileReader from applying `Gzip` decompression on an underlying file. */
|
||||
FileReader *BLI_filereader_new_gzip(FileReader *base) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,22 +10,10 @@
|
||||
* Bugs can be reported to <bug-glibc@prep.ai.mit.edu>.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined WIN32 && !defined _LIBC
|
||||
|
||||
# if defined(__cplusplus) || (defined(__STDC__) && __STDC__)
|
||||
# undef __P
|
||||
# define __P(protos) protos
|
||||
# else /* Not C++ or ANSI C. */
|
||||
# undef __P
|
||||
# define __P(protos) ()
|
||||
/* We can get away without defining `const' here only because in this file
|
||||
* it is used only inside the prototype for `fnmatch', which is elided in
|
||||
* non-ANSI C where `const' is problematical. */
|
||||
# endif /* C++ or ANSI C. */
|
||||
# undef __P
|
||||
# define __P(protos) protos
|
||||
|
||||
/* We #undef these before defining them because some losing systems
|
||||
* (HP-UX A.08.07 for example) define these in <unistd.h>. */
|
||||
@@ -57,7 +45,3 @@ extern int fnmatch __P((const char *__pattern, const char *__string, int __flags
|
||||
# endif
|
||||
# include <fnmatch.h> // IWYU pragma: export
|
||||
#endif /* defined WIN32 && !defined _LIBC */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_sys_types.h" /* for bool */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _GHASH_INTERNAL_ATTR
|
||||
#ifndef GHASH_INTERNAL_API
|
||||
# ifdef __GNUC__
|
||||
@@ -642,7 +638,3 @@ GSet *BLI_gset_int_new_ex(const char *info,
|
||||
GSet *BLI_gset_int_new(const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _GSQueue GSQueue;
|
||||
|
||||
GSQueue *BLI_gsqueue_new(size_t elem_size);
|
||||
@@ -42,7 +38,3 @@ void BLI_gsqueue_push(GSQueue *queue, const void *item);
|
||||
* Free the queue's data and the queue itself.
|
||||
*/
|
||||
void BLI_gsqueue_free(GSQueue *queue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Jenkins Lookup3 Hash Functions.
|
||||
* Source: http://burtleburtle.net/bob/c/lookup3.c
|
||||
@@ -108,7 +104,3 @@ BLI_INLINE void BLI_hash_pointer_to_color(const void *ptr, int *r, int *g, int *
|
||||
*g = (hash & 0x00ff00) >> 8;
|
||||
*b = hash & 0x0000ff;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Heap;
|
||||
struct HeapNode;
|
||||
typedef struct Heap Heap;
|
||||
@@ -79,7 +75,3 @@ void *BLI_heap_node_ptr(const HeapNode *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNU
|
||||
* Only for checking internal errors (gtest).
|
||||
*/
|
||||
bool BLI_heap_is_valid(const Heap *heap);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct HeapSimple;
|
||||
typedef struct HeapSimple HeapSimple;
|
||||
|
||||
@@ -45,7 +41,3 @@ float BLI_heapsimple_top_value(const HeapSimple *heap) ATTR_WARN_UNUSED_RESULT A
|
||||
* Pop the top node off the heap and return its pointer.
|
||||
*/
|
||||
void *BLI_heapsimple_pop_min(HeapSimple *heap) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BLI_Iterator {
|
||||
void *current; /* current pointer we iterate over */
|
||||
void *data; /* stored data required for this iterator */
|
||||
@@ -49,7 +45,3 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
|
||||
callback_end_func(&iter_macro); \
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,14 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void BLI_jitter_init(float (*jitarr)[2], int num);
|
||||
void BLI_jitterate1(float (*jit1)[2], float (*jit2)[2], int num, float radius1);
|
||||
void BLI_jitterate2(float (*jit1)[2], float (*jit2)[2], int num, float radius2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -19,10 +19,6 @@
|
||||
# define KD_DIMS 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct KDTree;
|
||||
typedef struct KDTree KDTree;
|
||||
|
||||
@@ -94,11 +90,6 @@ int BLI_kdtree_nd_(range_search_with_len_squared_cb)(
|
||||
const void *user_data),
|
||||
const void *user_data) ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
template<typename Fn>
|
||||
inline void BLI_kdtree_nd_(range_search_cb_cpp)(const KDTree *tree,
|
||||
const float co[KD_DIMS],
|
||||
@@ -132,7 +123,6 @@ inline int BLI_kdtree_nd_(find_nearest_cb_cpp)(const KDTree *tree,
|
||||
&fn,
|
||||
r_nearest);
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef _BLI_CONCAT_AUX
|
||||
#undef _BLI_CONCAT
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct BLI_mempool;
|
||||
struct MemArena;
|
||||
|
||||
@@ -92,7 +88,3 @@ LinkNode *BLI_linklist_sort_r(LinkNode *list,
|
||||
BLI_linklist_prepend_nlink(listp, ptr, (LinkNode *)alloca(sizeof(LinkNode)))
|
||||
#define BLI_linklist_append_alloca(list_pair, ptr) \
|
||||
BLI_linklist_append_nlink(list_pair, ptr, (LinkNode *)alloca(sizeof(LinkNode)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct LockfreeLinkNode {
|
||||
struct LockfreeLinkNode *next;
|
||||
/* NOTE: "Subclass" this structure to add custom-defined data. */
|
||||
@@ -54,7 +50,3 @@ LockfreeLinkNode *BLI_linklist_lockfree_begin(LockfreeLinkList *list);
|
||||
/* NOTE: These functions are safe for use from threads. */
|
||||
|
||||
void BLI_linklist_lockfree_insert(LockfreeLinkList *list, LockfreeLinkNode *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -37,27 +37,13 @@
|
||||
#define BLI_LINKSTACK_SIZE(var) BLI_mempool_len(var##_pool_)
|
||||
|
||||
/* Check for `decltype()` or `typeof()` support. */
|
||||
#if defined(__cplusplus)
|
||||
# define BLI_LINKSTACK_PUSH(var, ptr) \
|
||||
(CHECK_TYPE_INLINE_NONCONST(ptr, decltype(var##_type_)), \
|
||||
BLI_linklist_prepend_pool(&(var), ptr, var##_pool_))
|
||||
# define BLI_LINKSTACK_POP(var) \
|
||||
(decltype(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : NULL)
|
||||
# define BLI_LINKSTACK_POP_DEFAULT(var, r) \
|
||||
(decltype(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : r)
|
||||
#elif defined(__GNUC__)
|
||||
# define BLI_LINKSTACK_PUSH(var, ptr) \
|
||||
(CHECK_TYPE_INLINE_NONCONST(ptr, typeof(var##_type_)), \
|
||||
BLI_linklist_prepend_pool(&(var), ptr, var##_pool_))
|
||||
# define BLI_LINKSTACK_POP(var) \
|
||||
(typeof(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : NULL)
|
||||
# define BLI_LINKSTACK_POP_DEFAULT(var, r) \
|
||||
(typeof(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : r)
|
||||
#else /* Non GCC/C++. */
|
||||
# define BLI_LINKSTACK_PUSH(var, ptr) (BLI_linklist_prepend_pool(&(var), ptr, var##_pool_))
|
||||
# define BLI_LINKSTACK_POP(var) (var ? BLI_linklist_pop_pool(&(var), var##_pool_) : NULL)
|
||||
# define BLI_LINKSTACK_POP_DEFAULT(var, r) (var ? BLI_linklist_pop_pool(&(var), var##_pool_) : r)
|
||||
#endif
|
||||
#define BLI_LINKSTACK_PUSH(var, ptr) \
|
||||
(CHECK_TYPE_INLINE_NONCONST(ptr, decltype(var##_type_)), \
|
||||
BLI_linklist_prepend_pool(&(var), ptr, var##_pool_))
|
||||
#define BLI_LINKSTACK_POP(var) \
|
||||
(decltype(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : NULL)
|
||||
#define BLI_LINKSTACK_POP_DEFAULT(var, r) \
|
||||
(decltype(var##_type_))(var ? BLI_linklist_pop_pool(&(var), var##_pool_) : r)
|
||||
|
||||
#define BLI_LINKSTACK_SWAP(var_a, var_b) \
|
||||
{ \
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "DNA_listBase.h"
|
||||
// struct ListBase;
|
||||
// struct LinkData;
|
||||
#include <cstddef>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_compiler_compat.h"
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
/**
|
||||
* Returns the position of \a vlink within \a listbase, numbering from 0, or -1 if not found.
|
||||
@@ -268,7 +265,7 @@ void BLI_movelisttolist_reverse(struct ListBase *dst, struct ListBase *src) ATTR
|
||||
* Split `original_listbase` after given `vlink`, putting the remaining of the list into given
|
||||
* `split_listbase`.
|
||||
*
|
||||
* \note If `vlink` is nullptr, it is considered as 'the item before the first item', so the whole
|
||||
* \note If `vlink` is NULL, it is considered as 'the item before the first item', so the whole
|
||||
* list is moved from `original_listbase` to `split_listbase`.
|
||||
*/
|
||||
void BLI_listbase_split_after(struct ListBase *original_listbase,
|
||||
@@ -297,11 +294,11 @@ BLI_INLINE bool BLI_listbase_is_single(const struct ListBase *lb)
|
||||
}
|
||||
BLI_INLINE bool BLI_listbase_is_empty(const struct ListBase *lb)
|
||||
{
|
||||
return (lb->first == (void *)0);
|
||||
return (lb->first == (void *)nullptr);
|
||||
}
|
||||
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
|
||||
{
|
||||
lb->first = lb->last = (void *)0;
|
||||
lb->first = lb->last = (void *)nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,10 +315,10 @@ bool BLI_listbase_validate(struct ListBase *lb);
|
||||
*/
|
||||
BLI_INLINE bool BLI_listbase_equal(const struct ListBase *a, const struct ListBase *b)
|
||||
{
|
||||
if (a == NULL) {
|
||||
return b == NULL;
|
||||
if (a == nullptr) {
|
||||
return b == nullptr;
|
||||
}
|
||||
if (b == NULL) {
|
||||
if (b == nullptr) {
|
||||
return false;
|
||||
}
|
||||
return a->first == b->first && a->last == b->last;
|
||||
@@ -370,7 +367,7 @@ struct LinkData *BLI_genericNodeN(void *data);
|
||||
((void)0)
|
||||
|
||||
#define LISTBASE_FOREACH(type, var, list) \
|
||||
for (type var = (type)((list)->first); var != NULL; var = (type)(((Link *)(var))->next))
|
||||
for (type var = (type)((list)->first); var != nullptr; var = (type)(((Link *)(var))->next))
|
||||
|
||||
/**
|
||||
* A version of #LISTBASE_FOREACH that supports incrementing an index variable at every step.
|
||||
@@ -378,18 +375,18 @@ struct LinkData *BLI_genericNodeN(void *data);
|
||||
* incrementation.
|
||||
*/
|
||||
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var) \
|
||||
for (type var = (((void)(index_var = 0)), (type)((list)->first)); var != NULL; \
|
||||
for (type var = (((void)(index_var = 0)), (type)((list)->first)); var != nullptr; \
|
||||
var = (type)(((Link *)(var))->next), index_var++)
|
||||
|
||||
#define LISTBASE_FOREACH_BACKWARD(type, var, list) \
|
||||
for (type var = (type)((list)->last); var != NULL; var = (type)(((Link *)(var))->prev))
|
||||
for (type var = (type)((list)->last); var != nullptr; var = (type)(((Link *)(var))->prev))
|
||||
|
||||
/**
|
||||
* A version of #LISTBASE_FOREACH that supports removing the item we're looping over.
|
||||
*/
|
||||
#define LISTBASE_FOREACH_MUTABLE(type, var, list) \
|
||||
for (type var = (type)((list)->first), *var##_iter_next; \
|
||||
((var != NULL) ? ((void)(var##_iter_next = (type)(((Link *)(var))->next)), 1) : 0); \
|
||||
((var != nullptr) ? ((void)(var##_iter_next = (type)(((Link *)(var))->next)), 1) : 0); \
|
||||
var = var##_iter_next)
|
||||
|
||||
/**
|
||||
@@ -397,14 +394,9 @@ struct LinkData *BLI_genericNodeN(void *data);
|
||||
*/
|
||||
#define LISTBASE_FOREACH_BACKWARD_MUTABLE(type, var, list) \
|
||||
for (type var = (type)((list)->last), *var##_iter_prev; \
|
||||
((var != NULL) ? ((void)(var##_iter_prev = (type)(((Link *)(var))->prev)), 1) : 0); \
|
||||
((var != nullptr) ? ((void)(var##_iter_prev = (type)(((Link *)(var))->prev)), 1) : 0); \
|
||||
var = var##_iter_prev)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
BLI_INLINE bool operator==(const ListBase &a, const ListBase &b)
|
||||
{
|
||||
return BLI_listbase_equal(&a, &b);
|
||||
@@ -420,5 +412,3 @@ template<typename T, typename Fn> T *BLI_listbase_find(const ListBase &listbase,
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,7 +58,7 @@ static const int NAN_INT = 0x7FC00000;
|
||||
#endif
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_base_inline.c" // IWYU pragma: export
|
||||
# include "intern/math_base_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
||||
@@ -66,10 +66,6 @@ static const int NAN_INT = 0x7FC00000;
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************************* Float ******************************/
|
||||
|
||||
/* `powf` is really slow for raising to integer powers. */
|
||||
@@ -353,7 +349,3 @@ float ceil_power_of_10(float f);
|
||||
# define BLI_ASSERT_ZERO_M4(m) (void)(m)
|
||||
# define BLI_ASSERT_UNIT_M3(m) (void)(m)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MINLINE float safe_divide(float a, float b);
|
||||
MINLINE float safe_modf(float a, float b);
|
||||
MINLINE float safe_logf(float a, float base);
|
||||
@@ -26,10 +22,6 @@ MINLINE float safe_asinf(float a);
|
||||
MINLINE float safe_acosf(float a);
|
||||
MINLINE float safe_powf(float base, float exponent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_base_safe_inline.c" // IWYU pragma: export
|
||||
# include "intern/math_base_safe_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
@@ -10,11 +10,6 @@
|
||||
|
||||
#include "BLI_build_config.h"
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Search the value from LSB to MSB for a set bit. Returns index of this bit. */
|
||||
|
||||
@@ -61,9 +56,5 @@ MINLINE float uint_as_float(unsigned int i);
|
||||
MINLINE float xor_fl(float x, int y);
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_bits_inline.c" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
# include "intern/math_bits_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_math_inline.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Defines
|
||||
* \{ */
|
||||
@@ -181,10 +177,6 @@ MINLINE void cpack_cpy_3ub(unsigned char r_col[3], unsigned int pack);
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_color_inline.c"
|
||||
# include "intern/math_color_inline.cc"
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/******************** Blending Modes **********************
|
||||
* - byte function assume straight alpha
|
||||
* - float functions assume premultiplied alpha
|
||||
@@ -126,10 +122,6 @@ MINLINE void blend_color_interpolate_float(float dst[4],
|
||||
const float src2[4],
|
||||
float t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_color_blend_inline.c" // IWYU pragma: export
|
||||
# include "intern/math_color_blend_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Polygons
|
||||
* \{ */
|
||||
@@ -1383,16 +1379,12 @@ float geodesic_distance_propagate_across_triangle(
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Inline Definitions
|
||||
* \{ */
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_geom_inline.c" // IWYU pragma: export
|
||||
# include "intern/math_geom_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
||||
|
||||
@@ -8,21 +8,17 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* add platform/compiler checks here if it is not supported */
|
||||
/* all platforms support forcing inline so this is always enabled */
|
||||
#define BLI_MATH_DO_INLINE 1
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# ifdef _MSC_VER
|
||||
# define MINLINE static __forceinline
|
||||
# define MINLINE inline __forceinline
|
||||
# define MALWAYS_INLINE MINLINE
|
||||
# else
|
||||
# define MINLINE static inline
|
||||
# define MALWAYS_INLINE static inline __attribute__((always_inline)) __attribute__((unused))
|
||||
# define MINLINE inline
|
||||
# define MALWAYS_INLINE inline __attribute__((always_inline)) __attribute__((unused))
|
||||
# endif
|
||||
#else
|
||||
# define MINLINE
|
||||
@@ -33,7 +29,3 @@ extern "C" {
|
||||
#ifdef __GNUC__
|
||||
# define BLI_MATH_GCC_WARN_PRAGMA 1
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Init
|
||||
* \{ */
|
||||
@@ -587,7 +583,3 @@ void print_m4(const char *str, const float m[4][4]);
|
||||
#define print_m4_id(M) print_m4(STRINGIFY(M), M)
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,22 +13,6 @@
|
||||
#include "BLI_utildefines.h"
|
||||
#include "DNA_vec_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Conversion Defines
|
||||
* \{ */
|
||||
|
||||
#define RAD2DEG(_rad) ((_rad) * (180.0 / M_PI))
|
||||
#define DEG2RAD(_deg) ((_deg) * (M_PI / 180.0))
|
||||
|
||||
#define RAD2DEGF(_rad) ((_rad) * (float)(180.0 / M_PI))
|
||||
#define DEG2RADF(_deg) ((_deg) * (float)(M_PI / 180.0))
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Quaternions
|
||||
* Stored in (w, x, y, z) order.
|
||||
@@ -454,7 +438,3 @@ bool mat3_from_axis_conversion(
|
||||
bool mat3_from_axis_conversion_single(int src_axis, int dst_axis, float r_mat[3][3]);
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_math_inline.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
@@ -111,7 +107,3 @@ bool BLI_newton3d_solve(Newton3D_DeltaFunc func_delta,
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
@@ -61,7 +57,3 @@ void BLI_covariance_m3_v3n(const float (*cos_v3)[3],
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Time Constants Definitions
|
||||
* \{ */
|
||||
@@ -55,7 +51,3 @@ void BLI_math_time_seconds_decompose(double seconds,
|
||||
/* None. */
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Init
|
||||
* \{ */
|
||||
@@ -635,7 +631,7 @@ void mul_vn_db(double *array_tar, int size, double f);
|
||||
* \{ */
|
||||
|
||||
#if BLI_MATH_DO_INLINE
|
||||
# include "intern/math_vector_inline.c" // IWYU pragma: export
|
||||
# include "intern/math_vector_inline.cc" // IWYU pragma: export
|
||||
#endif
|
||||
|
||||
#ifdef BLI_MATH_GCC_WARN_PRAGMA
|
||||
@@ -643,7 +639,3 @@ void mul_vn_db(double *array_tar, int size, double f);
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <cstddef>
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/**
|
||||
* A reasonable standard buffer size, big enough to not cause much internal fragmentation,
|
||||
@@ -23,20 +21,39 @@ extern "C" {
|
||||
#define BLI_MEMARENA_STD_BUFSIZE MEM_SIZE_OPTIMAL(1 << 14)
|
||||
|
||||
struct MemArena;
|
||||
typedef struct MemArena MemArena;
|
||||
|
||||
struct MemArena *BLI_memarena_new(size_t bufsize,
|
||||
const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
|
||||
MemArena *BLI_memarena_new(size_t bufsize,
|
||||
const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
|
||||
ATTR_NONNULL(2) ATTR_MALLOC;
|
||||
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_malloc(struct MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_calloc(struct MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_align(struct MemArena *ma, size_t align) ATTR_NONNULL(1);
|
||||
void *BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT
|
||||
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_malloc(MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_calloc(MemArena *ma) ATTR_NONNULL(1);
|
||||
void BLI_memarena_use_align(MemArena *ma, size_t align) ATTR_NONNULL(1);
|
||||
void *BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2);
|
||||
void *BLI_memarena_calloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT
|
||||
void *BLI_memarena_calloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2);
|
||||
|
||||
/**
|
||||
* C++ templates for convenience.
|
||||
*/
|
||||
template<typename T>
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC T *BLI_memarena_alloc(MemArena *ma,
|
||||
const size_t num = 1)
|
||||
{
|
||||
static_assert(std::is_trivial_v<T>,
|
||||
"Only trivial types may be allocated with BLI_memarena_alloc");
|
||||
return static_cast<T *>(BLI_memarena_alloc(ma, sizeof(T) * num));
|
||||
}
|
||||
template<typename T>
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC T *BLI_memarena_calloc(MemArena *ma,
|
||||
const size_t num = 1)
|
||||
{
|
||||
static_assert(std::is_trivial_v<T>,
|
||||
"Only trivial types may be allocated with BLI_memarena_calloc");
|
||||
return static_cast<T *>(BLI_memarena_calloc(ma, sizeof(T) * num));
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfer ownership of allocated blocks from `ma_src` into `ma_dst`,
|
||||
* cleaning the contents of `ma_src`.
|
||||
@@ -54,7 +71,3 @@ void BLI_memarena_merge(MemArena *ma_dst, MemArena *ma_src) ATTR_NONNULL(1, 2);
|
||||
* otherwise be freed and recreated.
|
||||
*/
|
||||
void BLI_memarena_clear(MemArena *ma) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BLI_MEM_BLOCK_CHUNK_SIZE (1 << 15) /* 32KiB */
|
||||
|
||||
struct BLI_memblock;
|
||||
@@ -53,7 +49,3 @@ void *BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATT
|
||||
*/
|
||||
void *BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 512kb, good default for small elems. */
|
||||
#define BLI_MEMITER_DEFAULT_SIZE (1 << 19)
|
||||
|
||||
@@ -65,7 +61,3 @@ bool BLI_memiter_iter_done(const BLI_memiter_handle *iter) ATTR_NONNULL(1);
|
||||
void *BLI_memiter_iter_step(BLI_memiter_handle *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
|
||||
void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size) ATTR_WARN_UNUSED_RESULT
|
||||
ATTR_NONNULL(1, 2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -13,17 +13,9 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* it may be defined already */
|
||||
#ifndef __BLI_UTILDEFINES_H__
|
||||
bool BLI_memory_is_zero(const void *arr, size_t size);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BLI_MEMORY_UTILS_H__ */
|
||||
|
||||
@@ -10,15 +10,11 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <type_traits>
|
||||
|
||||
struct BLI_mempool;
|
||||
struct BLI_mempool_chunk;
|
||||
|
||||
typedef struct BLI_mempool BLI_mempool;
|
||||
|
||||
BLI_mempool *BLI_mempool_create(unsigned int esize,
|
||||
unsigned int elem_num,
|
||||
unsigned int pchunk,
|
||||
@@ -28,6 +24,27 @@ void *BLI_mempool_alloc(BLI_mempool *pool) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT A
|
||||
ATTR_NONNULL(1);
|
||||
void *BLI_mempool_calloc(BLI_mempool *pool)
|
||||
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1);
|
||||
|
||||
/**
|
||||
* C++ templates for convenience.
|
||||
*/
|
||||
template<typename T>
|
||||
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
|
||||
ATTR_NONNULL(1) T *BLI_mempool_alloc(BLI_mempool *pool)
|
||||
{
|
||||
static_assert(std::is_trivial_v<T>,
|
||||
"Only trivial types may be allocated with BLI_mempool_alloc");
|
||||
return static_cast<T *>(BLI_mempool_alloc(pool));
|
||||
}
|
||||
template<typename T>
|
||||
ATTR_MALLOC ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL
|
||||
ATTR_NONNULL(1) T *BLI_mempool_calloc(BLI_mempool *pool)
|
||||
{
|
||||
static_assert(std::is_trivial_v<T>,
|
||||
"Only trivial types may be allocated with BLI_mempool_calloc");
|
||||
return static_cast<T *>(BLI_mempool_calloc(pool));
|
||||
}
|
||||
|
||||
/**
|
||||
* Free an element from the mempool.
|
||||
*
|
||||
@@ -65,7 +82,7 @@ void *BLI_mempool_as_arrayN(BLI_mempool *pool,
|
||||
ATTR_NONNULL(1, 2);
|
||||
|
||||
#ifndef NDEBUG
|
||||
void BLI_mempool_set_memory_debug(void);
|
||||
void BLI_mempool_set_memory_debug();
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -74,11 +91,11 @@ void BLI_mempool_set_memory_debug(void);
|
||||
*/
|
||||
|
||||
/** \note Private structure. */
|
||||
typedef struct BLI_mempool_iter {
|
||||
struct BLI_mempool_iter {
|
||||
BLI_mempool *pool;
|
||||
struct BLI_mempool_chunk *curchunk;
|
||||
unsigned int curindex;
|
||||
} BLI_mempool_iter;
|
||||
};
|
||||
|
||||
/** #BLI_mempool.flag */
|
||||
enum {
|
||||
@@ -102,7 +119,3 @@ void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter) ATTR_NONNULL
|
||||
* Step over the iterator, returning the mempool item or NULL.
|
||||
*/
|
||||
void *BLI_mempool_iterstep(BLI_mempool_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Memory-mapped file IO that implements all the OS-specific details and error handling. */
|
||||
|
||||
struct BLI_mmap_file;
|
||||
@@ -36,7 +32,3 @@ void *BLI_mmap_get_pointer(BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT;
|
||||
size_t BLI_mmap_get_length(const BLI_mmap_file *file) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
void BLI_mmap_free(BLI_mmap_file *file) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern const uchar BLI_noise_hash_uchar_512[512]; /* Quiet warning. */
|
||||
|
||||
float BLI_noise_hnoise(float noisesize, float x, float y, float z);
|
||||
@@ -136,7 +132,3 @@ float BLI_noise_cell(float x, float y, float z);
|
||||
* Returns a vector/point/color in `r_ca`, using point hash-array directly.
|
||||
*/
|
||||
void BLI_noise_cell_v3(float x, float y, float z, float r_ca[3]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct MemArena;
|
||||
|
||||
/**
|
||||
@@ -44,7 +40,3 @@ void BLI_polyfill_calc(const float (*coords)[2],
|
||||
|
||||
/* default size of polyfill arena */
|
||||
#define BLI_POLYFILL_ARENA_SIZE MEM_SIZE_OPTIMAL(1 << 14)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Heap;
|
||||
struct MemArena;
|
||||
|
||||
@@ -63,7 +59,3 @@ float BLI_polyfill_edge_calc_rotate_beauty__area(const float v1[3],
|
||||
|
||||
/* avoid realloc's when creating new structures for polyfill ngons */
|
||||
#define BLI_POLYFILL_ALLOC_NGON_RESERVE 64
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct Quadric {
|
||||
double a2, ab, ac, ad, b2, bc, bd, c2, cd, d2;
|
||||
} Quadric;
|
||||
@@ -35,7 +31,3 @@ void BLI_quadric_mul(Quadric *a, double scalar);
|
||||
|
||||
double BLI_quadric_evaluate(const Quadric *q, const double v[3]);
|
||||
bool BLI_quadric_optimize(const Quadric *q, double v[3], double epsilon);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
* \brief Random number functions.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* RNG is an abstract random number generator type that avoids using globals.
|
||||
* Always use this instead of the global RNG unless you have a good reason,
|
||||
@@ -102,7 +98,3 @@ void BLI_halton_1d(unsigned int prime, double offset, int n, double *r);
|
||||
void BLI_halton_2d(const unsigned int prime[2], double offset[2], int n, double *r);
|
||||
void BLI_halton_3d(const unsigned int prime[3], double offset[3], int n, double *r);
|
||||
void BLI_hammersley_1d(unsigned int n, double *r);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
struct rctf;
|
||||
struct rcti;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Determine if a `rect` is empty.
|
||||
* An empty `rect` is one with a zero (or negative) width or height.
|
||||
@@ -202,7 +198,3 @@ BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
|
||||
{
|
||||
return (rct->ymax - rct->ymin);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
|
||||
struct ScanFillVert;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ScanFillContext {
|
||||
ListBase fillvertbase;
|
||||
ListBase filledgebase;
|
||||
@@ -120,7 +116,3 @@ void BLI_scanfill_end_arena(ScanFillContext *sf_ctx, struct MemArena *arena);
|
||||
bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
|
||||
ListBase *remvertbase,
|
||||
ListBase *remedgebase);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,12 +15,10 @@
|
||||
* For true UUIDs, see `BLI_uuid.h`.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "DNA_session_uid_types.h"
|
||||
|
||||
#include "BLI_hash.hh"
|
||||
|
||||
/** Generate new UID which is unique throughout the Blender session. */
|
||||
SessionUID BLI_session_uid_generate(void);
|
||||
|
||||
@@ -37,14 +35,6 @@ uint64_t BLI_session_uid_hash_uint64(const SessionUID *uid);
|
||||
uint BLI_session_uid_ghash_hash(const void *uid_v);
|
||||
bool BLI_session_uid_ghash_compare(const void *lhs_v, const void *rhs_v);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# include "BLI_hash.hh"
|
||||
|
||||
namespace blender {
|
||||
|
||||
inline bool operator==(const SessionUID &lhs, const SessionUID &rhs)
|
||||
@@ -62,5 +52,3 @@ template<> struct DefaultHash<SessionUID> {
|
||||
};
|
||||
|
||||
} // namespace blender
|
||||
|
||||
#endif
|
||||
|
||||
@@ -10,12 +10,6 @@
|
||||
* SIMD instruction support.
|
||||
*/
|
||||
|
||||
/* sse2neon.h uses a newer pre-processor which is no available for C language when using MSVC.
|
||||
* For the consistency require C++ for all build configurations. */
|
||||
#if !defined(__cplusplus)
|
||||
# error Including BLI_simd.hh requires C++
|
||||
#endif
|
||||
|
||||
#if (defined(__ARM_NEON) || (defined(_M_ARM64) && defined(_MSC_VER))) && \
|
||||
defined(WITH_SSE2NEON) && !defined(DISABLE_SSE2NEON)
|
||||
/* SSE/SSE2 emulation on ARM Neon. Match SSE precision. */
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define AREATEX_WIDTH 160
|
||||
#define AREATEX_HEIGHT 560
|
||||
#define AREATEX_PITCH (AREATEX_WIDTH * 2)
|
||||
@@ -35,7 +31,3 @@ extern const unsigned char areaTexBytes[];
|
||||
* - GPU: GPU_R8 texture format and GPU_DATA_UBYTE data format.
|
||||
*/
|
||||
extern const unsigned char searchTexBytes[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Quick sort (re-entrant). */
|
||||
typedef int (*BLI_sort_cmp_t)(const void *a, const void *b, void *ctx);
|
||||
|
||||
@@ -22,7 +18,3 @@ void BLI_qsort_r(void *a, size_t n, size_t es, BLI_sort_cmp_t cmp, void *thunk)
|
||||
__attribute__((nonnull(1, 5)))
|
||||
#endif
|
||||
;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \note keep \a sort_value first,
|
||||
* so cmp functions can be reused.
|
||||
@@ -41,7 +37,3 @@ int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_);
|
||||
|
||||
int BLI_sortutil_cmp_int(const void *a_, const void *b_);
|
||||
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct BLI_Stack BLI_Stack;
|
||||
|
||||
BLI_Stack *BLI_stack_new_ex(size_t elem_size,
|
||||
@@ -89,7 +85,3 @@ size_t BLI_stack_count(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONN
|
||||
* Returns true if the stack is empty, false otherwise
|
||||
*/
|
||||
bool BLI_stack_is_empty(const BLI_Stack *stack) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -14,10 +14,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Buffer size of maximum `uint64` plus commas and terminator. */
|
||||
#define BLI_STR_FORMAT_UINT64_GROUPED_SIZE 27
|
||||
|
||||
@@ -589,10 +585,6 @@ bool BLI_string_elem_split_by_delim(const char *haystack,
|
||||
* \note `ARRAY_SIZE` allows pointers on some platforms.
|
||||
* \{ */
|
||||
|
||||
#ifndef __cplusplus
|
||||
# define STRNCPY(dst, src) BLI_strncpy(dst, src, ARRAY_SIZE(dst))
|
||||
#endif
|
||||
|
||||
#define STRNCPY_RLEN(dst, src) BLI_strncpy_rlen(dst, src, ARRAY_SIZE(dst))
|
||||
#define SNPRINTF(dst, format, ...) BLI_snprintf(dst, ARRAY_SIZE(dst), format, __VA_ARGS__)
|
||||
#define SNPRINTF_RLEN(dst, format, ...) \
|
||||
@@ -674,8 +666,6 @@ void BLI_string_debug_size_after_nil(char *str, size_t str_maxncpy);
|
||||
#endif /* !WITH_STRSIZE_DEBUG */
|
||||
|
||||
/** \} */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy source string str into the destination dst of a size known at a compile time.
|
||||
@@ -688,5 +678,3 @@ template<size_t N> inline char *STRNCPY(char (&dst)[N], const char *src)
|
||||
{
|
||||
return BLI_strncpy(dst, src, N);
|
||||
}
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum eStrCursorJumpType {
|
||||
STRCUR_JUMP_NONE,
|
||||
STRCUR_JUMP_DELIM,
|
||||
@@ -64,7 +60,3 @@ void BLI_str_cursor_step_bounds_utf8(
|
||||
/** A UTF32 version of #BLI_str_cursor_step_bounds_utf8 */
|
||||
void BLI_str_cursor_step_bounds_utf32(
|
||||
const char32_t *str, int str_maxlen, int pos, int *r_start, int *r_end);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
char *BLI_strncpy_utf8(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy)
|
||||
ATTR_NONNULL(1, 2);
|
||||
size_t BLI_strncpy_utf8_rlen(char *__restrict dst,
|
||||
@@ -263,7 +259,3 @@ int BLI_str_utf8_offset_from_column_with_tabs(const char *str,
|
||||
#define STRNCPY_UTF8_RLEN(dst, src) BLI_strncpy_utf8_rlen(dst, src, ARRAY_SIZE(dst))
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
* Unicode characters as UTF-8 strings.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Notes:
|
||||
* - Last portion should include the official assigned name.
|
||||
* - Please do not add defines here that are not actually in use.
|
||||
@@ -87,7 +83,3 @@ extern "C" {
|
||||
#define BLI_STR_UTF8_CIRCLED_WHITE_BULLET "\xe2\xa6\xbe"
|
||||
/** u2B2E: `⬮` Generic Mouse */
|
||||
#define BLI_STR_UTF8_BLACK_VERTICAL_ELLIPSE "\xe2\xac\xae"
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -18,10 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__linux__) || defined(__GNU__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
|
||||
defined(__FreeBSD_kernel__) || defined(__HAIKU__)
|
||||
|
||||
@@ -69,7 +65,3 @@ typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned char uchar;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** \file
|
||||
* \ingroup bli
|
||||
*/
|
||||
@@ -52,7 +48,3 @@ void BLI_windows_handle_exception(void *exception);
|
||||
#else
|
||||
# define BLI_SYSTEM_PID_H <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
#include "BLI_threads.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct BLI_mempool;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
@@ -370,8 +366,4 @@ void BLI_task_isolate(void (*func)(void *userdata), void *userdata);
|
||||
|
||||
/** \} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Sets `tempdir` from `dirpath` when it's a valid directory.
|
||||
* Simple sanitize operations are performed and a trailing slash is ensured.
|
||||
@@ -33,7 +29,3 @@ bool BLI_temp_directory_path_copy_if_valid(char *tempdir,
|
||||
* The directory path is always null-terminated.
|
||||
*/
|
||||
void BLI_temp_directory_path_get(char *tempdir, const size_t tempdir_maxncpy) ATTR_NONNULL(1);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** For tables, button in UI, etc. */
|
||||
#define BLENDER_MAX_THREADS 1024
|
||||
|
||||
@@ -195,7 +191,3 @@ void BLI_thread_queue_nowait(ThreadQueue *queue);
|
||||
# define BLI_thread_local_get(name) name
|
||||
# define BLI_thread_local_set(name, value) name = value
|
||||
#endif /* defined(__APPLE__) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Return an indication of time, expressed as seconds since some fixed point.
|
||||
* Successive calls are guaranteed to generate values greater than or equal to the last call.
|
||||
@@ -27,7 +23,3 @@ extern long int BLI_time_now_seconds_i(void);
|
||||
* \param ms: Number of milliseconds to sleep
|
||||
*/
|
||||
void BLI_time_sleep_ms(int ms);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Generate time-code/frame number string and store in \a str
|
||||
*
|
||||
@@ -62,7 +58,3 @@ size_t BLI_timecode_string_from_time_seconds(char *str,
|
||||
size_t maxncpy,
|
||||
int brevity_level,
|
||||
float time_seconds) ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* \return A value of:
|
||||
* - < 0: the timer will be removed.
|
||||
@@ -44,7 +40,3 @@ void BLI_timer_free(void);
|
||||
/* This function is to be called next to BKE_CB_EVT_LOAD_PRE, to make sure the module
|
||||
* is properly configured for the new file. */
|
||||
void BLI_timer_on_file_load(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -334,11 +334,8 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
|
||||
/** \name Pointer Macros
|
||||
* \{ */
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define POINTER_OFFSET(v, ofs) ((typeof(v))((char *)(v) + (ofs)))
|
||||
#else
|
||||
# define POINTER_OFFSET(v, ofs) ((void *)((char *)(v) + (ofs)))
|
||||
#endif
|
||||
#define POINTER_OFFSET(v, ofs) \
|
||||
(reinterpret_cast<typename std::remove_reference<decltype(v)>::type>((char *)(v) + (ofs)))
|
||||
|
||||
/* Warning-free macros for storing ints in pointers. Use these _only_
|
||||
* for storing an int in a pointer, not a pointer in an int (64bit)! */
|
||||
@@ -358,7 +355,7 @@ inline constexpr int64_t power_of_2_max(const int64_t x)
|
||||
*
|
||||
* \{ */
|
||||
|
||||
/** Performs `offsetof(typeof(data), member) + sizeof((data)->member)` for non-gcc compilers. */
|
||||
/** Performs `offsetof(decltype(data), member) + sizeof((data)->member)` for non-gcc compilers. */
|
||||
#define OFFSETOF_STRUCT_AFTER(_struct, _member) \
|
||||
((size_t)(((const char *)&((_struct)->_member)) - ((const char *)(_struct))) + \
|
||||
sizeof((_struct)->_member))
|
||||
|
||||
@@ -15,20 +15,21 @@
|
||||
#include "DNA_uuid_types.h"
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_string_ref.hh"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <initializer_list>
|
||||
#include <iosfwd>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* UUID generator for random (version 4) UUIDs. See RFC4122 section 4.4.
|
||||
* This function is not thread-safe. */
|
||||
bUUID BLI_uuid_generate_random(void);
|
||||
bUUID BLI_uuid_generate_random();
|
||||
|
||||
/**
|
||||
* Return the UUID nil value, consisting of all-zero fields.
|
||||
*/
|
||||
bUUID BLI_uuid_nil(void);
|
||||
bUUID BLI_uuid_nil();
|
||||
|
||||
/** Return true only if this is the nil UUID. */
|
||||
bool BLI_uuid_is_nil(bUUID uuid);
|
||||
@@ -53,15 +54,6 @@ void BLI_uuid_format(char *buffer, bUUID uuid) ATTR_NONNULL();
|
||||
*/
|
||||
bool BLI_uuid_parse_string(bUUID *uuid, const char *buffer) ATTR_NONNULL();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
# include <initializer_list>
|
||||
# include <iosfwd>
|
||||
# include <string>
|
||||
|
||||
# include "BLI_string_ref.hh"
|
||||
|
||||
/** Output the UUID as formatted ASCII string, see #BLI_uuid_format(). */
|
||||
std::ostream &operator<<(std::ostream &stream, bUUID uuid);
|
||||
|
||||
@@ -98,5 +90,3 @@ bool operator!=(bUUID uuid1, bUUID uuid2);
|
||||
bool operator<(bUUID uuid1, bUUID uuid2);
|
||||
|
||||
} // namespace blender
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Object;
|
||||
struct ProjCameraInfo;
|
||||
|
||||
@@ -50,7 +46,3 @@ void BLI_uvproject_from_view_ortho(float target[2], float source[3], const float
|
||||
* So we can adjust scale with keeping the struct private.
|
||||
*/
|
||||
void BLI_uvproject_camera_info_scale(struct ProjCameraInfo *uci, float scale_x, float scale_y);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Calculate the index number of a voxel, given x/y/z integer coords and resolution vector. */
|
||||
#define BLI_VOXEL_INDEX(x, y, z, res) \
|
||||
((int64_t)(x) + (int64_t)(y) * (int64_t)(res)[0] + \
|
||||
@@ -20,7 +16,3 @@ extern "C" {
|
||||
/* All input coordinates must be in bounding box 0.0 - 1.0. */
|
||||
|
||||
float BLI_voxel_sample_trilinear(const float *data, const int res[3], const float co[3]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -38,10 +38,6 @@
|
||||
|
||||
/* These definitions are also in BLI_math for simplicity. */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(_USE_MATH_DEFINES)
|
||||
# define _USE_MATH_DEFINES
|
||||
#endif
|
||||
@@ -117,7 +113,3 @@ bool BLI_windows_execute_self(const char *parameters,
|
||||
const bool wait,
|
||||
const bool elevated,
|
||||
const bool silent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -21,38 +21,38 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
intern/BLI_assert.c
|
||||
intern/BLI_assert.cc
|
||||
intern/BLI_color.cc
|
||||
intern/BLI_dial_2d.c
|
||||
intern/BLI_dynstr.c
|
||||
intern/BLI_dial_2d.cc
|
||||
intern/BLI_dynstr.cc
|
||||
intern/BLI_filelist.cc
|
||||
intern/BLI_ghash.c
|
||||
intern/BLI_ghash.cc
|
||||
intern/BLI_ghash_utils.cc
|
||||
intern/BLI_heap.c
|
||||
intern/BLI_heap_simple.c
|
||||
intern/BLI_heap.cc
|
||||
intern/BLI_heap_simple.cc
|
||||
intern/BLI_kdopbvh.cc
|
||||
intern/BLI_linklist.c
|
||||
intern/BLI_linklist_lockfree.c
|
||||
intern/BLI_memarena.c
|
||||
intern/BLI_memblock.c
|
||||
intern/BLI_memiter.c
|
||||
intern/BLI_mempool.c
|
||||
intern/BLI_mmap.c
|
||||
intern/BLI_linklist.cc
|
||||
intern/BLI_linklist_lockfree.cc
|
||||
intern/BLI_memarena.cc
|
||||
intern/BLI_memblock.cc
|
||||
intern/BLI_memiter.cc
|
||||
intern/BLI_mempool.cc
|
||||
intern/BLI_mmap.cc
|
||||
intern/BLI_subprocess.cc
|
||||
intern/BLI_timer.c
|
||||
intern/BLI_timer.cc
|
||||
intern/array_store.cc
|
||||
intern/array_store_utils.cc
|
||||
intern/array_utils.c
|
||||
intern/array_utils.cc
|
||||
intern/astar.c
|
||||
intern/array_utils_c.cc
|
||||
intern/astar.cc
|
||||
intern/atomic_disjoint_set.cc
|
||||
intern/bit_bool_conversion.cc
|
||||
intern/bit_ref.cc
|
||||
intern/bit_span.cc
|
||||
intern/bitmap.c
|
||||
intern/bitmap.cc
|
||||
intern/bitmap_draw_2d.cc
|
||||
intern/boxpack_2d.c
|
||||
intern/buffer.c
|
||||
intern/boxpack_2d.cc
|
||||
intern/buffer.cc
|
||||
intern/cache_mutex.cc
|
||||
intern/compute_context.cc
|
||||
intern/convexhull_2d.cc
|
||||
@@ -60,21 +60,21 @@ set(SRC
|
||||
intern/cpp_types.cc
|
||||
intern/delaunay_2d.cc
|
||||
intern/dot_export.cc
|
||||
intern/easing.c
|
||||
intern/endian_switch.c
|
||||
intern/expr_pylike_eval.c
|
||||
intern/easing.cc
|
||||
intern/endian_switch.cc
|
||||
intern/expr_pylike_eval.cc
|
||||
intern/fftw.cc
|
||||
intern/fileops.cc
|
||||
intern/fileops_c.cc
|
||||
intern/filereader_file.c
|
||||
intern/filereader_gzip.c
|
||||
intern/filereader_memory.c
|
||||
intern/filereader_zstd.c
|
||||
intern/fnmatch.c
|
||||
intern/filereader_file.cc
|
||||
intern/filereader_gzip.cc
|
||||
intern/filereader_memory.cc
|
||||
intern/filereader_zstd.cc
|
||||
intern/fnmatch.cc
|
||||
intern/generic_vector_array.cc
|
||||
intern/generic_virtual_array.cc
|
||||
intern/generic_virtual_vector_array.cc
|
||||
intern/gsqueue.c
|
||||
intern/gsqueue.cc
|
||||
intern/hash_md5.cc
|
||||
intern/hash_mm2a.cc
|
||||
intern/hash_mm3.cc
|
||||
@@ -83,26 +83,26 @@ set(SRC
|
||||
intern/index_mask.cc
|
||||
intern/index_mask_expression.cc
|
||||
intern/index_range.cc
|
||||
intern/jitter_2d.c
|
||||
intern/kdtree_1d.c
|
||||
intern/kdtree_2d.c
|
||||
intern/kdtree_3d.c
|
||||
intern/kdtree_4d.c
|
||||
intern/jitter_2d.cc
|
||||
intern/kdtree_1d.cc
|
||||
intern/kdtree_2d.cc
|
||||
intern/kdtree_3d.cc
|
||||
intern/kdtree_4d.cc
|
||||
intern/lasso_2d.cc
|
||||
intern/lazy_threading.cc
|
||||
intern/length_parameterize.cc
|
||||
intern/listbase.cc
|
||||
intern/math_base.cc
|
||||
intern/math_base_inline.c
|
||||
intern/math_base_safe_inline.c
|
||||
intern/math_base_inline.cc
|
||||
intern/math_base_safe_inline.cc
|
||||
intern/math_basis_types.cc
|
||||
intern/math_bits_inline.c
|
||||
intern/math_bits_inline.cc
|
||||
intern/math_boolean.cc
|
||||
intern/math_color.cc
|
||||
intern/math_color_blend_inline.c
|
||||
intern/math_color_inline.c
|
||||
intern/math_color_blend_inline.cc
|
||||
intern/math_color_inline.cc
|
||||
intern/math_geom.cc
|
||||
intern/math_geom_inline.c
|
||||
intern/math_geom_inline.cc
|
||||
intern/math_half.cc
|
||||
intern/math_interp.cc
|
||||
intern/math_matrix.cc
|
||||
@@ -114,7 +114,7 @@ set(SRC
|
||||
intern/math_time.cc
|
||||
intern/math_vec.cc
|
||||
intern/math_vector.cc
|
||||
intern/math_vector_inline.c
|
||||
intern/math_vector_inline.cc
|
||||
intern/memory_cache.cc
|
||||
intern/memory_counter.cc
|
||||
intern/memory_utils.cc
|
||||
@@ -131,37 +131,37 @@ set(SRC
|
||||
intern/rand.cc
|
||||
intern/rct.cc
|
||||
intern/resource_scope.cc
|
||||
intern/scanfill.c
|
||||
intern/scanfill_utils.c
|
||||
intern/scanfill.cc
|
||||
intern/scanfill_utils.cc
|
||||
intern/serialize.cc
|
||||
intern/session_uid.c
|
||||
intern/smaa_textures.c
|
||||
intern/sort.c
|
||||
intern/sort_utils.c
|
||||
intern/stack.c
|
||||
intern/session_uid.cc
|
||||
intern/smaa_textures.cc
|
||||
intern/sort.cc
|
||||
intern/sort_utils.cc
|
||||
intern/stack.cc
|
||||
intern/storage.cc
|
||||
intern/string.c
|
||||
intern/string_cursor_utf8.c
|
||||
intern/string.cc
|
||||
intern/string_cursor_utf8.cc
|
||||
intern/string_ref.cc
|
||||
intern/string_search.cc
|
||||
intern/string_utf8.cc
|
||||
intern/string_utils.cc
|
||||
intern/system.c
|
||||
intern/system.cc
|
||||
intern/task_graph.cc
|
||||
intern/task_iterator.c
|
||||
intern/task_iterator.cc
|
||||
intern/task_pool.cc
|
||||
intern/task_range.cc
|
||||
intern/task_scheduler.cc
|
||||
intern/tempfile.cc
|
||||
intern/threads.cc
|
||||
intern/time.c
|
||||
intern/timecode.c
|
||||
intern/time.cc
|
||||
intern/timecode.cc
|
||||
intern/timeit.cc
|
||||
intern/uuid.cc
|
||||
intern/uvproject.cc
|
||||
intern/vector.cc
|
||||
intern/virtual_array.cc
|
||||
intern/voxel.c
|
||||
intern/voxel.cc
|
||||
intern/winstuff.cc
|
||||
intern/winstuff_dir.cc
|
||||
intern/winstuff_registration.cc
|
||||
@@ -428,7 +428,7 @@ set(LIB
|
||||
|
||||
if(NOT WITH_PYTHON_MODULE)
|
||||
list(APPEND SRC
|
||||
intern/BLI_args.c
|
||||
intern/BLI_args.cc
|
||||
|
||||
BLI_args.h
|
||||
)
|
||||
@@ -496,13 +496,13 @@ endif()
|
||||
|
||||
# no need to compile object files for inline headers.
|
||||
set_source_files_properties(
|
||||
intern/math_base_inline.c
|
||||
intern/math_base_safe_inline.c
|
||||
intern/math_bits_inline.c
|
||||
intern/math_color_blend_inline.c
|
||||
intern/math_color_inline.c
|
||||
intern/math_geom_inline.c
|
||||
intern/math_vector_inline.c
|
||||
intern/math_base_inline.cc
|
||||
intern/math_base_safe_inline.cc
|
||||
intern/math_bits_inline.cc
|
||||
intern/math_color_blend_inline.cc
|
||||
intern/math_color_inline.cc
|
||||
intern/math_geom_inline.cc
|
||||
intern/math_vector_inline.cc
|
||||
PROPERTIES HEADER_FILE_ONLY TRUE
|
||||
)
|
||||
|
||||
|
||||
@@ -7,9 +7,8 @@
|
||||
* \brief A general argument parsing module
|
||||
*/
|
||||
|
||||
#include <ctype.h> /* for tolower */
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <cctype> /* for tolower */
|
||||
#include <cstdio>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -22,26 +21,26 @@
|
||||
static char NO_DOCS[] = "NO DOCUMENTATION SPECIFIED";
|
||||
|
||||
struct bArgDoc;
|
||||
typedef struct bArgDoc {
|
||||
struct bArgDoc {
|
||||
struct bArgDoc *next, *prev;
|
||||
const char *short_arg;
|
||||
const char *long_arg;
|
||||
const char *documentation;
|
||||
bool done;
|
||||
} bArgDoc;
|
||||
};
|
||||
|
||||
typedef struct bAKey {
|
||||
struct bAKey {
|
||||
const char *arg;
|
||||
uintptr_t pass; /* cast easier */
|
||||
int case_str; /* case specific or not */
|
||||
} bAKey;
|
||||
};
|
||||
|
||||
typedef struct bArgument {
|
||||
struct bArgument {
|
||||
bAKey *key;
|
||||
BA_ArgCallback func;
|
||||
void *data;
|
||||
bArgDoc *doc;
|
||||
} bArgument;
|
||||
};
|
||||
|
||||
struct bArgs {
|
||||
ListBase docs;
|
||||
@@ -59,7 +58,7 @@ struct bArgs {
|
||||
|
||||
static uint case_strhash(const void *ptr)
|
||||
{
|
||||
const char *s = ptr;
|
||||
const char *s = static_cast<const char *>(ptr);
|
||||
uint i = 0;
|
||||
uchar c;
|
||||
|
||||
@@ -72,14 +71,14 @@ static uint case_strhash(const void *ptr)
|
||||
|
||||
static uint keyhash(const void *ptr)
|
||||
{
|
||||
const bAKey *k = ptr;
|
||||
const bAKey *k = static_cast<const bAKey *>(ptr);
|
||||
return case_strhash(k->arg); /* ^ BLI_ghashutil_inthash((void *)k->pass); */
|
||||
}
|
||||
|
||||
static bool keycmp(const void *a, const void *b)
|
||||
{
|
||||
const bAKey *ka = a;
|
||||
const bAKey *kb = b;
|
||||
const bAKey *ka = static_cast<const bAKey *>(a);
|
||||
const bAKey *kb = static_cast<const bAKey *>(b);
|
||||
if (ka->pass == kb->pass || ka->pass == -1 || kb->pass == -1) { /* -1 is wildcard for pass */
|
||||
if (ka->case_str == 1 || kb->case_str == 1) {
|
||||
return (BLI_strcasecmp(ka->arg, kb->arg) != 0);
|
||||
@@ -97,20 +96,20 @@ static bArgument *lookUp(bArgs *ba, const char *arg, int pass, int case_str)
|
||||
key.pass = pass;
|
||||
key.arg = arg;
|
||||
|
||||
return BLI_ghash_lookup(ba->items, &key);
|
||||
return static_cast<bArgument *>(BLI_ghash_lookup(ba->items, &key));
|
||||
}
|
||||
|
||||
/** Default print function. */
|
||||
ATTR_PRINTF_FORMAT(2, 0)
|
||||
static void args_print_wrapper(void *UNUSED(user_data), const char *format, va_list args)
|
||||
static void args_print_wrapper(void * /*user_data*/, const char *format, va_list args)
|
||||
{
|
||||
vprintf(format, args);
|
||||
}
|
||||
|
||||
bArgs *BLI_args_create(int argc, const char **argv)
|
||||
{
|
||||
bArgs *ba = MEM_callocN(sizeof(bArgs), "bArgs");
|
||||
ba->passes = MEM_callocN(sizeof(int) * argc, "bArgs passes");
|
||||
bArgs *ba = MEM_cnew<bArgs>("bArgs");
|
||||
ba->passes = MEM_cnew_array<int>(argc, "bArgs passes");
|
||||
ba->items = BLI_ghash_new(keyhash, keycmp, "bArgs passes gh");
|
||||
BLI_listbase_clear(&ba->docs);
|
||||
ba->argc = argc;
|
||||
@@ -119,7 +118,7 @@ bArgs *BLI_args_create(int argc, const char **argv)
|
||||
/* Must be initialized by #BLI_args_pass_set. */
|
||||
ba->current_pass = 0;
|
||||
|
||||
BLI_args_print_fn_set(ba, args_print_wrapper, NULL);
|
||||
BLI_args_print_fn_set(ba, args_print_wrapper, nullptr);
|
||||
|
||||
return ba;
|
||||
}
|
||||
@@ -167,9 +166,9 @@ static bArgDoc *internalDocs(bArgs *ba,
|
||||
{
|
||||
bArgDoc *d;
|
||||
|
||||
d = MEM_callocN(sizeof(bArgDoc), "bArgDoc");
|
||||
d = MEM_cnew<bArgDoc>("bArgDoc");
|
||||
|
||||
if (doc == NULL) {
|
||||
if (doc == nullptr) {
|
||||
doc = NO_DOCS;
|
||||
}
|
||||
|
||||
@@ -203,8 +202,8 @@ static void internalAdd(
|
||||
a->key->case_str == 1 ? "not " : "");
|
||||
}
|
||||
|
||||
a = MEM_callocN(sizeof(bArgument), "bArgument");
|
||||
key = MEM_callocN(sizeof(bAKey), "bAKey");
|
||||
a = MEM_cnew<bArgument>("bArgument");
|
||||
key = MEM_cnew<bAKey>("bAKey");
|
||||
|
||||
key->arg = arg;
|
||||
key->pass = pass;
|
||||
@@ -278,9 +277,7 @@ void BLI_args_print_arg_doc(bArgs *ba, const char *arg)
|
||||
|
||||
void BLI_args_print_other_doc(bArgs *ba)
|
||||
{
|
||||
bArgDoc *d;
|
||||
|
||||
for (d = ba->docs.first; d; d = d->next) {
|
||||
LISTBASE_FOREACH (bArgDoc *, d, &ba->docs) {
|
||||
if (d->done == 0) {
|
||||
internalDocPrint(ba, d);
|
||||
}
|
||||
@@ -289,7 +286,7 @@ void BLI_args_print_other_doc(bArgs *ba)
|
||||
|
||||
bool BLI_args_has_other_doc(const bArgs *ba)
|
||||
{
|
||||
for (const bArgDoc *d = ba->docs.first; d; d = d->next) {
|
||||
LISTBASE_FOREACH (const bArgDoc *, d, &ba->docs) {
|
||||
if (d->done == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -306,8 +303,8 @@ void BLI_args_parse(bArgs *ba, int pass, BA_ArgCallback default_cb, void *defaul
|
||||
if (ba->passes[i] == 0) {
|
||||
/* -1 signal what side of the comparison it is */
|
||||
bArgument *a = lookUp(ba, ba->argv[i], pass, -1);
|
||||
BA_ArgCallback func = NULL;
|
||||
void *data = NULL;
|
||||
BA_ArgCallback func = nullptr;
|
||||
void *data = nullptr;
|
||||
|
||||
if (a) {
|
||||
func = a->func;
|
||||
@@ -14,8 +14,8 @@
|
||||
# include "BLI_system.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
void _BLI_assert_print_pos(const char *file, const int line, const char *function, const char *id)
|
||||
{
|
||||
@@ -36,7 +36,7 @@ struct Dial {
|
||||
|
||||
Dial *BLI_dial_init(const float start_position[2], float threshold)
|
||||
{
|
||||
Dial *dial = MEM_callocN(sizeof(Dial), "dial");
|
||||
Dial *dial = MEM_cnew<Dial>("dial");
|
||||
|
||||
copy_v2_v2(dial->center, start_position);
|
||||
dial->threshold_squared = threshold * threshold;
|
||||
@@ -7,9 +7,9 @@
|
||||
* Dynamically sized string ADT.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h> /* malloc */
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib> /* malloc */
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_dynstr.h"
|
||||
#include "BLI_memarena.h"
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
/***/
|
||||
|
||||
typedef struct DynStrElem DynStrElem;
|
||||
struct DynStrElem {
|
||||
DynStrElem *next;
|
||||
|
||||
@@ -36,37 +35,31 @@ struct DynStr {
|
||||
|
||||
DynStr *BLI_dynstr_new(void)
|
||||
{
|
||||
DynStr *ds = MEM_mallocN(sizeof(*ds), "DynStr");
|
||||
ds->elems = ds->last = NULL;
|
||||
ds->curlen = 0;
|
||||
ds->memarena = NULL;
|
||||
|
||||
return ds;
|
||||
return MEM_cnew<DynStr>("DynStr");
|
||||
}
|
||||
|
||||
DynStr *BLI_dynstr_new_memarena(void)
|
||||
{
|
||||
DynStr *ds = MEM_mallocN(sizeof(*ds), "DynStr");
|
||||
ds->elems = ds->last = NULL;
|
||||
ds->curlen = 0;
|
||||
DynStr *ds = MEM_cnew<DynStr>("DynStr");
|
||||
ds->memarena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
|
||||
|
||||
return ds;
|
||||
}
|
||||
|
||||
BLI_INLINE void *dynstr_alloc(DynStr *__restrict ds, size_t size)
|
||||
template<typename T> inline T *dynstr_alloc(DynStr *__restrict ds, size_t num = 1)
|
||||
{
|
||||
return ds->memarena ? BLI_memarena_alloc(ds->memarena, size) : malloc(size);
|
||||
return ds->memarena ? BLI_memarena_alloc<T>(ds->memarena, num) :
|
||||
static_cast<T *>(malloc(num * sizeof(T)));
|
||||
}
|
||||
|
||||
void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr)
|
||||
{
|
||||
DynStrElem *dse = dynstr_alloc(ds, sizeof(*dse));
|
||||
DynStrElem *dse = dynstr_alloc<DynStrElem>(ds);
|
||||
int cstrlen = strlen(cstr);
|
||||
|
||||
dse->str = dynstr_alloc(ds, cstrlen + 1);
|
||||
dse->str = dynstr_alloc<char>(ds, cstrlen + 1);
|
||||
memcpy(dse->str, cstr, cstrlen + 1);
|
||||
dse->next = NULL;
|
||||
dse->next = nullptr;
|
||||
|
||||
if (!ds->last) {
|
||||
ds->last = ds->elems = dse;
|
||||
@@ -80,13 +73,13 @@ void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr)
|
||||
|
||||
void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len)
|
||||
{
|
||||
DynStrElem *dse = dynstr_alloc(ds, sizeof(*dse));
|
||||
DynStrElem *dse = dynstr_alloc<DynStrElem>(ds);
|
||||
int cstrlen = BLI_strnlen(cstr, len);
|
||||
|
||||
dse->str = dynstr_alloc(ds, cstrlen + 1);
|
||||
dse->str = dynstr_alloc<char>(ds, cstrlen + 1);
|
||||
memcpy(dse->str, cstr, cstrlen);
|
||||
dse->str[cstrlen] = '\0';
|
||||
dse->next = NULL;
|
||||
dse->next = nullptr;
|
||||
|
||||
if (!ds->last) {
|
||||
ds->last = ds->elems = dse;
|
||||
@@ -148,7 +141,7 @@ void BLI_dynstr_get_cstring_ex(const DynStr *__restrict ds, char *__restrict ret
|
||||
|
||||
char *BLI_dynstr_get_cstring(const DynStr *ds)
|
||||
{
|
||||
char *rets = MEM_mallocN(ds->curlen + 1, "dynstr_cstring");
|
||||
char *rets = static_cast<char *>(MEM_mallocN(ds->curlen + 1, "dynstr_cstring"));
|
||||
BLI_dynstr_get_cstring_ex(ds, rets);
|
||||
return rets;
|
||||
}
|
||||
@@ -167,7 +160,7 @@ void BLI_dynstr_clear(DynStr *ds)
|
||||
}
|
||||
}
|
||||
|
||||
ds->elems = ds->last = NULL;
|
||||
ds->elems = ds->last = nullptr;
|
||||
ds->curlen = 0;
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
* for 'Abstract Data Types' (known as an ADT Hash Table).
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <climits>
|
||||
#include <cstdarg>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -61,19 +61,19 @@ BLI_STATIC_ASSERT(ARRAY_SIZE(hashsizes) == GHASH_MAX_SIZE, "Invalid 'hashsizes'
|
||||
#define GHASH_LIMIT_SHRINK(_nbkt) (((_nbkt) * 3) / 16)
|
||||
|
||||
/* WARNING! Keep in sync with ugly _gh_Entry in header!!! */
|
||||
typedef struct Entry {
|
||||
struct Entry {
|
||||
struct Entry *next;
|
||||
|
||||
void *key;
|
||||
} Entry;
|
||||
};
|
||||
|
||||
typedef struct GHashEntry {
|
||||
struct GHashEntry {
|
||||
Entry e;
|
||||
|
||||
void *val;
|
||||
} GHashEntry;
|
||||
};
|
||||
|
||||
typedef Entry GSetEntry;
|
||||
using GSetEntry = Entry;
|
||||
|
||||
#define GHASH_ENTRY_SIZE(_is_gset) ((_is_gset) ? sizeof(GSetEntry) : sizeof(GHashEntry))
|
||||
|
||||
@@ -116,7 +116,7 @@ BLI_INLINE void ghash_entry_copy(GHash *gh_dst,
|
||||
((GHashEntry *)src)->val;
|
||||
}
|
||||
else {
|
||||
((GHashEntry *)dst)->val = NULL;
|
||||
((GHashEntry *)dst)->val = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,7 +373,7 @@ BLI_INLINE Entry *ghash_lookup_entry_ex(const GHash *gh, const void *key, const
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -389,15 +389,15 @@ BLI_INLINE Entry *ghash_lookup_entry_prev_ex(GHash *gh,
|
||||
{
|
||||
/* If we do not store GHash, not worth computing it for each entry here!
|
||||
* Typically, comparison function will be quicker, and since it's needed in the end anyway... */
|
||||
for (Entry *e_prev = NULL, *e = gh->buckets[bucket_index]; e; e_prev = e, e = e->next) {
|
||||
for (Entry *e_prev = nullptr, *e = gh->buckets[bucket_index]; e; e_prev = e, e = e->next) {
|
||||
if (UNLIKELY(gh->cmpfp(key, e->key) == false)) {
|
||||
*r_e_prev = e_prev;
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
*r_e_prev = NULL;
|
||||
return NULL;
|
||||
*r_e_prev = nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,12 +416,12 @@ static GHash *ghash_new(GHashHashFP hashfp,
|
||||
const uint nentries_reserve,
|
||||
const uint flag)
|
||||
{
|
||||
GHash *gh = MEM_mallocN(sizeof(*gh), info);
|
||||
GHash *gh = MEM_cnew<GHash>(info);
|
||||
|
||||
gh->hashfp = hashfp;
|
||||
gh->cmpfp = cmpfp;
|
||||
|
||||
gh->buckets = NULL;
|
||||
gh->buckets = nullptr;
|
||||
gh->flag = flag;
|
||||
|
||||
ghash_buckets_reset(gh, nentries_reserve);
|
||||
@@ -438,7 +438,7 @@ static GHash *ghash_new(GHashHashFP hashfp,
|
||||
*/
|
||||
BLI_INLINE void ghash_insert_ex(GHash *gh, void *key, void *val, const uint bucket_index)
|
||||
{
|
||||
GHashEntry *e = BLI_mempool_alloc(gh->entrypool);
|
||||
GHashEntry *e = BLI_mempool_alloc<GHashEntry>(gh->entrypool);
|
||||
|
||||
BLI_assert((gh->flag & GHASH_FLAG_ALLOW_DUPES) || (BLI_ghash_haskey(gh, key) == 0));
|
||||
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
|
||||
@@ -473,7 +473,7 @@ BLI_INLINE void ghash_insert_ex_keyonly_entry(GHash *gh,
|
||||
*/
|
||||
BLI_INLINE void ghash_insert_ex_keyonly(GHash *gh, void *key, const uint bucket_index)
|
||||
{
|
||||
Entry *e = BLI_mempool_alloc(gh->entrypool);
|
||||
Entry *e = BLI_mempool_alloc<Entry>(gh->entrypool);
|
||||
|
||||
BLI_assert((gh->flag & GHASH_FLAG_ALLOW_DUPES) || (BLI_ghash_haskey(gh, key) == 0));
|
||||
BLI_assert((gh->flag & GHASH_FLAG_IS_GSET) != 0);
|
||||
@@ -583,13 +583,13 @@ static Entry *ghash_remove_ex(GHash *gh,
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a random entry and return it (or NULL if empty), caller must free from gh->entrypool.
|
||||
* Remove a random entry and return it (or nullptr if empty), caller must free from gh->entrypool.
|
||||
*/
|
||||
static Entry *ghash_pop(GHash *gh, GHashIterState *state)
|
||||
{
|
||||
uint curr_bucket = state->curr_bucket;
|
||||
if (gh->nentries == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* NOTE: using first_bucket_index here allows us to avoid potential
|
||||
@@ -600,7 +600,7 @@ static Entry *ghash_pop(GHash *gh, GHashIterState *state)
|
||||
Entry *e = gh->buckets[curr_bucket];
|
||||
BLI_assert(e);
|
||||
|
||||
ghash_remove_ex(gh, e->key, NULL, NULL, curr_bucket);
|
||||
ghash_remove_ex(gh, e->key, nullptr, nullptr, curr_bucket);
|
||||
|
||||
state->curr_bucket = curr_bucket;
|
||||
return e;
|
||||
@@ -638,7 +638,7 @@ static GHash *ghash_copy(const GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopy
|
||||
GHash *gh_new;
|
||||
uint i;
|
||||
/* This allows us to be sure to get the same number of buckets in gh_new as in ghash. */
|
||||
const uint reserve_nentries_new = MAX2(GHASH_LIMIT_GROW(gh->nbuckets) - 1, gh->nentries);
|
||||
const uint reserve_nentries_new = std::max(GHASH_LIMIT_GROW(gh->nbuckets) - 1, gh->nentries);
|
||||
|
||||
BLI_assert(!valcopyfp || !(gh->flag & GHASH_FLAG_IS_GSET));
|
||||
|
||||
@@ -651,7 +651,7 @@ static GHash *ghash_copy(const GHash *gh, GHashKeyCopyFP keycopyfp, GHashValCopy
|
||||
Entry *e;
|
||||
|
||||
for (e = gh->buckets[i]; e; e = e->next) {
|
||||
Entry *e_new = BLI_mempool_alloc(gh_new->entrypool);
|
||||
Entry *e_new = BLI_mempool_alloc<Entry>(gh_new->entrypool);
|
||||
ghash_entry_copy(gh_new, e_new, gh, e, keycopyfp, valcopyfp);
|
||||
|
||||
/* Warning!
|
||||
@@ -720,19 +720,19 @@ void *BLI_ghash_replace_key(GHash *gh, void *key)
|
||||
const uint hash = ghash_keyhash(gh, key);
|
||||
const uint bucket_index = ghash_bucket_index(gh, hash);
|
||||
GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
|
||||
if (e != NULL) {
|
||||
if (e != nullptr) {
|
||||
void *key_prev = e->e.key;
|
||||
e->e.key = key;
|
||||
return key_prev;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *BLI_ghash_lookup(const GHash *gh, const void *key)
|
||||
{
|
||||
GHashEntry *e = (GHashEntry *)ghash_lookup_entry(gh, key);
|
||||
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
|
||||
return e ? e->val : NULL;
|
||||
return e ? e->val : nullptr;
|
||||
}
|
||||
|
||||
void *BLI_ghash_lookup_default(const GHash *gh, const void *key, void *val_default)
|
||||
@@ -746,7 +746,7 @@ void **BLI_ghash_lookup_p(GHash *gh, const void *key)
|
||||
{
|
||||
GHashEntry *e = (GHashEntry *)ghash_lookup_entry(gh, key);
|
||||
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
|
||||
return e ? &e->val : NULL;
|
||||
return e ? &e->val : nullptr;
|
||||
}
|
||||
|
||||
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val)
|
||||
@@ -754,10 +754,10 @@ bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val)
|
||||
const uint hash = ghash_keyhash(gh, key);
|
||||
const uint bucket_index = ghash_bucket_index(gh, hash);
|
||||
GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
|
||||
const bool haskey = (e != NULL);
|
||||
const bool haskey = (e != nullptr);
|
||||
|
||||
if (!haskey) {
|
||||
e = BLI_mempool_alloc(gh->entrypool);
|
||||
e = BLI_mempool_alloc<GHashEntry>(gh->entrypool);
|
||||
ghash_insert_ex_keyonly_entry(gh, key, bucket_index, (Entry *)e);
|
||||
}
|
||||
|
||||
@@ -770,13 +770,13 @@ bool BLI_ghash_ensure_p_ex(GHash *gh, const void *key, void ***r_key, void ***r_
|
||||
const uint hash = ghash_keyhash(gh, key);
|
||||
const uint bucket_index = ghash_bucket_index(gh, hash);
|
||||
GHashEntry *e = (GHashEntry *)ghash_lookup_entry_ex(gh, key, bucket_index);
|
||||
const bool haskey = (e != NULL);
|
||||
const bool haskey = (e != nullptr);
|
||||
|
||||
if (!haskey) {
|
||||
/* Pass 'key' in case we resize. */
|
||||
e = BLI_mempool_alloc(gh->entrypool);
|
||||
e = BLI_mempool_alloc<GHashEntry>(gh->entrypool);
|
||||
ghash_insert_ex_keyonly_entry(gh, (void *)key, bucket_index, (Entry *)e);
|
||||
e->e.key = NULL; /* caller must re-assign */
|
||||
e->e.key = nullptr; /* caller must re-assign */
|
||||
}
|
||||
|
||||
*r_key = &e->e.key;
|
||||
@@ -806,19 +806,19 @@ void *BLI_ghash_popkey(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp)
|
||||
|
||||
const uint hash = ghash_keyhash(gh, key);
|
||||
const uint bucket_index = ghash_bucket_index(gh, hash);
|
||||
GHashEntry *e = (GHashEntry *)ghash_remove_ex(gh, key, keyfreefp, NULL, bucket_index);
|
||||
GHashEntry *e = (GHashEntry *)ghash_remove_ex(gh, key, keyfreefp, nullptr, bucket_index);
|
||||
BLI_assert(!(gh->flag & GHASH_FLAG_IS_GSET));
|
||||
if (e) {
|
||||
void *val = e->val;
|
||||
BLI_mempool_free(gh->entrypool, e);
|
||||
return val;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool BLI_ghash_haskey(const GHash *gh, const void *key)
|
||||
{
|
||||
return (ghash_lookup_entry(gh, key) != NULL);
|
||||
return (ghash_lookup_entry(gh, key) != nullptr);
|
||||
}
|
||||
|
||||
bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val)
|
||||
@@ -835,7 +835,7 @@ bool BLI_ghash_pop(GHash *gh, GHashIterState *state, void **r_key, void **r_val)
|
||||
return true;
|
||||
}
|
||||
|
||||
*r_key = *r_val = NULL;
|
||||
*r_key = *r_val = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -887,7 +887,7 @@ void BLI_ghash_flag_clear(GHash *gh, uint flag)
|
||||
|
||||
GHashIterator *BLI_ghashIterator_new(GHash *gh)
|
||||
{
|
||||
GHashIterator *ghi = MEM_mallocN(sizeof(*ghi), "ghash iterator");
|
||||
GHashIterator *ghi = MEM_cnew<GHashIterator>("ghash iterator");
|
||||
BLI_ghashIterator_init(ghi, gh);
|
||||
return ghi;
|
||||
}
|
||||
@@ -895,7 +895,7 @@ GHashIterator *BLI_ghashIterator_new(GHash *gh)
|
||||
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
|
||||
{
|
||||
ghi->gh = gh;
|
||||
ghi->curEntry = NULL;
|
||||
ghi->curEntry = nullptr;
|
||||
ghi->curBucket = UINT_MAX; /* wraps to zero */
|
||||
if (gh->nentries) {
|
||||
do {
|
||||
@@ -948,7 +948,7 @@ GSet *BLI_gset_new(GSetHashFP hashfp, GSetCmpFP cmpfp, const char *info)
|
||||
|
||||
GSet *BLI_gset_copy(const GSet *gs, GHashKeyCopyFP keycopyfp)
|
||||
{
|
||||
return (GSet *)ghash_copy((const GHash *)gs, keycopyfp, NULL);
|
||||
return (GSet *)ghash_copy((const GHash *)gs, keycopyfp, nullptr);
|
||||
}
|
||||
|
||||
uint BLI_gset_len(const GSet *gs)
|
||||
@@ -965,7 +965,7 @@ void BLI_gset_insert(GSet *gs, void *key)
|
||||
|
||||
bool BLI_gset_add(GSet *gs, void *key)
|
||||
{
|
||||
return ghash_insert_safe_keyonly((GHash *)gs, key, false, NULL);
|
||||
return ghash_insert_safe_keyonly((GHash *)gs, key, false, nullptr);
|
||||
}
|
||||
|
||||
bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key)
|
||||
@@ -973,13 +973,13 @@ bool BLI_gset_ensure_p_ex(GSet *gs, const void *key, void ***r_key)
|
||||
const uint hash = ghash_keyhash((GHash *)gs, key);
|
||||
const uint bucket_index = ghash_bucket_index((GHash *)gs, hash);
|
||||
GSetEntry *e = (GSetEntry *)ghash_lookup_entry_ex((const GHash *)gs, key, bucket_index);
|
||||
const bool haskey = (e != NULL);
|
||||
const bool haskey = (e != nullptr);
|
||||
|
||||
if (!haskey) {
|
||||
/* Pass 'key' in case we resize */
|
||||
e = BLI_mempool_alloc(((GHash *)gs)->entrypool);
|
||||
e = BLI_mempool_alloc<GSetEntry>(((GHash *)gs)->entrypool);
|
||||
ghash_insert_ex_keyonly_entry((GHash *)gs, (void *)key, bucket_index, (Entry *)e);
|
||||
e->key = NULL; /* caller must re-assign */
|
||||
e->key = nullptr; /* caller must re-assign */
|
||||
}
|
||||
|
||||
*r_key = &e->key;
|
||||
@@ -998,12 +998,12 @@ void *BLI_gset_replace_key(GSet *gs, void *key)
|
||||
|
||||
bool BLI_gset_remove(GSet *gs, const void *key, GSetKeyFreeFP keyfreefp)
|
||||
{
|
||||
return BLI_ghash_remove((GHash *)gs, key, keyfreefp, NULL);
|
||||
return BLI_ghash_remove((GHash *)gs, key, keyfreefp, nullptr);
|
||||
}
|
||||
|
||||
bool BLI_gset_haskey(const GSet *gs, const void *key)
|
||||
{
|
||||
return (ghash_lookup_entry((const GHash *)gs, key) != NULL);
|
||||
return (ghash_lookup_entry((const GHash *)gs, key) != nullptr);
|
||||
}
|
||||
|
||||
bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key)
|
||||
@@ -1017,23 +1017,23 @@ bool BLI_gset_pop(GSet *gs, GSetIterState *state, void **r_key)
|
||||
return true;
|
||||
}
|
||||
|
||||
*r_key = NULL;
|
||||
*r_key = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
void BLI_gset_clear_ex(GSet *gs, GSetKeyFreeFP keyfreefp, const uint nentries_reserve)
|
||||
{
|
||||
BLI_ghash_clear_ex((GHash *)gs, keyfreefp, NULL, nentries_reserve);
|
||||
BLI_ghash_clear_ex((GHash *)gs, keyfreefp, nullptr, nentries_reserve);
|
||||
}
|
||||
|
||||
void BLI_gset_clear(GSet *gs, GSetKeyFreeFP keyfreefp)
|
||||
{
|
||||
BLI_ghash_clear((GHash *)gs, keyfreefp, NULL);
|
||||
BLI_ghash_clear((GHash *)gs, keyfreefp, nullptr);
|
||||
}
|
||||
|
||||
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
|
||||
{
|
||||
BLI_ghash_free((GHash *)gs, keyfreefp, NULL);
|
||||
BLI_ghash_free((GHash *)gs, keyfreefp, nullptr);
|
||||
}
|
||||
|
||||
void BLI_gset_flag_set(GSet *gs, uint flag)
|
||||
@@ -1058,20 +1058,20 @@ void BLI_gset_flag_clear(GSet *gs, uint flag)
|
||||
void *BLI_gset_lookup(const GSet *gs, const void *key)
|
||||
{
|
||||
Entry *e = ghash_lookup_entry((const GHash *)gs, key);
|
||||
return e ? e->key : NULL;
|
||||
return e ? e->key : nullptr;
|
||||
}
|
||||
|
||||
void *BLI_gset_pop_key(GSet *gs, const void *key)
|
||||
{
|
||||
const uint hash = ghash_keyhash((GHash *)gs, key);
|
||||
const uint bucket_index = ghash_bucket_index((GHash *)gs, hash);
|
||||
Entry *e = ghash_remove_ex((GHash *)gs, key, NULL, NULL, bucket_index);
|
||||
Entry *e = ghash_remove_ex((GHash *)gs, key, nullptr, nullptr, bucket_index);
|
||||
if (e) {
|
||||
void *key_ret = e->key;
|
||||
BLI_mempool_free(((GHash *)gs)->entrypool, e);
|
||||
return key_ret;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -1193,11 +1193,11 @@ double BLI_gset_calc_quality_ex(const GSet *gs,
|
||||
|
||||
double BLI_ghash_calc_quality(const GHash *gh)
|
||||
{
|
||||
return BLI_ghash_calc_quality_ex(gh, NULL, NULL, NULL, NULL, NULL);
|
||||
return BLI_ghash_calc_quality_ex(gh, nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
double BLI_gset_calc_quality(const GSet *gs)
|
||||
{
|
||||
return BLI_ghash_calc_quality_ex((GHash *)gs, NULL, NULL, NULL, NULL, NULL);
|
||||
return BLI_ghash_calc_quality_ex((GHash *)gs, nullptr, nullptr, nullptr, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -8,8 +8,8 @@
|
||||
* A min-heap / priority queue ADT.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -27,7 +27,7 @@ struct HeapNode {
|
||||
};
|
||||
|
||||
struct HeapNode_Chunk {
|
||||
struct HeapNode_Chunk *prev;
|
||||
HeapNode_Chunk *prev;
|
||||
uint size;
|
||||
uint bufsize;
|
||||
HeapNode buf[0];
|
||||
@@ -41,7 +41,7 @@ struct HeapNode_Chunk {
|
||||
* \note keep type in sync with nodes_num in heap_node_alloc_chunk.
|
||||
*/
|
||||
#define HEAP_CHUNK_DEFAULT_NUM \
|
||||
(uint)(MEM_SIZE_OPTIMAL((1 << 16) - sizeof(struct HeapNode_Chunk)) / sizeof(HeapNode))
|
||||
(uint)(MEM_SIZE_OPTIMAL((1 << 16) - sizeof(HeapNode_Chunk)) / sizeof(HeapNode))
|
||||
|
||||
struct Heap {
|
||||
uint size;
|
||||
@@ -49,9 +49,9 @@ struct Heap {
|
||||
HeapNode **tree;
|
||||
|
||||
struct {
|
||||
/* Always keep at least one chunk (never NULL) */
|
||||
struct HeapNode_Chunk *chunk;
|
||||
/* when NULL, allocate a new chunk */
|
||||
/* Always keep at least one chunk (never nullptr) */
|
||||
HeapNode_Chunk *chunk;
|
||||
/* when nullptr, allocate a new chunk */
|
||||
HeapNode *free;
|
||||
} nodes;
|
||||
};
|
||||
@@ -85,7 +85,7 @@ static void heap_down(Heap *heap, uint i)
|
||||
HeapNode **const tree = heap->tree;
|
||||
const uint size = heap->size;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
const uint l = HEAP_LEFT(i);
|
||||
const uint r = HEAP_RIGHT(i);
|
||||
uint smallest = i;
|
||||
@@ -127,11 +127,10 @@ static void heap_up(Heap *heap, uint i)
|
||||
/** \name Internal Memory Management
|
||||
* \{ */
|
||||
|
||||
static struct HeapNode_Chunk *heap_node_alloc_chunk(uint nodes_num,
|
||||
struct HeapNode_Chunk *chunk_prev)
|
||||
static HeapNode_Chunk *heap_node_alloc_chunk(uint nodes_num, HeapNode_Chunk *chunk_prev)
|
||||
{
|
||||
struct HeapNode_Chunk *chunk = MEM_mallocN(
|
||||
sizeof(struct HeapNode_Chunk) + (sizeof(HeapNode) * nodes_num), __func__);
|
||||
HeapNode_Chunk *chunk = static_cast<HeapNode_Chunk *>(
|
||||
MEM_mallocN(sizeof(HeapNode_Chunk) + (sizeof(HeapNode) * nodes_num), __func__));
|
||||
chunk->prev = chunk_prev;
|
||||
chunk->bufsize = nodes_num;
|
||||
chunk->size = 0;
|
||||
@@ -144,10 +143,10 @@ static HeapNode *heap_node_alloc(Heap *heap)
|
||||
|
||||
if (heap->nodes.free) {
|
||||
node = heap->nodes.free;
|
||||
heap->nodes.free = heap->nodes.free->ptr;
|
||||
heap->nodes.free = static_cast<HeapNode *>(heap->nodes.free->ptr);
|
||||
}
|
||||
else {
|
||||
struct HeapNode_Chunk *chunk = heap->nodes.chunk;
|
||||
HeapNode_Chunk *chunk = heap->nodes.chunk;
|
||||
if (UNLIKELY(chunk->size == chunk->bufsize)) {
|
||||
chunk = heap->nodes.chunk = heap_node_alloc_chunk(HEAP_CHUNK_DEFAULT_NUM, chunk);
|
||||
}
|
||||
@@ -171,15 +170,15 @@ static void heap_node_free(Heap *heap, HeapNode *node)
|
||||
|
||||
Heap *BLI_heap_new_ex(uint reserve_num)
|
||||
{
|
||||
Heap *heap = MEM_mallocN(sizeof(Heap), __func__);
|
||||
Heap *heap = MEM_cnew<Heap>(__func__);
|
||||
/* ensure we have at least one so we can keep doubling it */
|
||||
heap->size = 0;
|
||||
heap->bufsize = MAX2(1u, reserve_num);
|
||||
heap->tree = MEM_mallocN(heap->bufsize * sizeof(HeapNode *), "BLIHeapTree");
|
||||
heap->bufsize = std::max(1u, reserve_num);
|
||||
heap->tree = MEM_cnew_array<HeapNode *>(heap->bufsize, "BLIHeapTree");
|
||||
|
||||
heap->nodes.chunk = heap_node_alloc_chunk(
|
||||
(reserve_num > 1) ? reserve_num : HEAP_CHUNK_DEFAULT_NUM, NULL);
|
||||
heap->nodes.free = NULL;
|
||||
(reserve_num > 1) ? reserve_num : HEAP_CHUNK_DEFAULT_NUM, nullptr);
|
||||
heap->nodes.free = nullptr;
|
||||
|
||||
return heap;
|
||||
}
|
||||
@@ -199,9 +198,9 @@ void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp)
|
||||
}
|
||||
}
|
||||
|
||||
struct HeapNode_Chunk *chunk = heap->nodes.chunk;
|
||||
HeapNode_Chunk *chunk = heap->nodes.chunk;
|
||||
do {
|
||||
struct HeapNode_Chunk *chunk_prev;
|
||||
HeapNode_Chunk *chunk_prev;
|
||||
chunk_prev = chunk->prev;
|
||||
MEM_freeN(chunk);
|
||||
chunk = chunk_prev;
|
||||
@@ -224,12 +223,12 @@ void BLI_heap_clear(Heap *heap, HeapFreeFP ptrfreefp)
|
||||
|
||||
/* Remove all except the last chunk */
|
||||
while (heap->nodes.chunk->prev) {
|
||||
struct HeapNode_Chunk *chunk_prev = heap->nodes.chunk->prev;
|
||||
HeapNode_Chunk *chunk_prev = heap->nodes.chunk->prev;
|
||||
MEM_freeN(heap->nodes.chunk);
|
||||
heap->nodes.chunk = chunk_prev;
|
||||
}
|
||||
heap->nodes.chunk->size = 0;
|
||||
heap->nodes.free = NULL;
|
||||
heap->nodes.free = nullptr;
|
||||
}
|
||||
|
||||
HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
|
||||
@@ -238,7 +237,8 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
|
||||
|
||||
if (UNLIKELY(heap->size >= heap->bufsize)) {
|
||||
heap->bufsize *= 2;
|
||||
heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
|
||||
heap->tree = static_cast<HeapNode **>(
|
||||
MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree)));
|
||||
}
|
||||
|
||||
node = heap_node_alloc(heap);
|
||||
@@ -258,7 +258,7 @@ HeapNode *BLI_heap_insert(Heap *heap, float value, void *ptr)
|
||||
|
||||
void BLI_heap_insert_or_update(Heap *heap, HeapNode **node_p, float value, void *ptr)
|
||||
{
|
||||
if (*node_p == NULL) {
|
||||
if (*node_p == nullptr) {
|
||||
*node_p = BLI_heap_insert(heap, value, ptr);
|
||||
}
|
||||
else {
|
||||
@@ -12,8 +12,8 @@
|
||||
* See BLI_heap.c for a more full featured heap implementation.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
/** \name HeapSimple Internal Structs
|
||||
* \{ */
|
||||
|
||||
typedef struct HeapSimpleNode {
|
||||
struct HeapSimpleNode {
|
||||
float value;
|
||||
void *ptr;
|
||||
} HeapSimpleNode;
|
||||
};
|
||||
|
||||
struct HeapSimple {
|
||||
uint size;
|
||||
@@ -138,11 +138,11 @@ static void heapsimple_up(HeapSimple *heap, uint i, float active_val, void *acti
|
||||
|
||||
HeapSimple *BLI_heapsimple_new_ex(uint reserve_num)
|
||||
{
|
||||
HeapSimple *heap = MEM_mallocN(sizeof(HeapSimple), __func__);
|
||||
HeapSimple *heap = MEM_cnew<HeapSimple>(__func__);
|
||||
/* ensure we have at least one so we can keep doubling it */
|
||||
heap->size = 0;
|
||||
heap->bufsize = MAX2(1u, reserve_num);
|
||||
heap->tree = MEM_mallocN(heap->bufsize * sizeof(HeapSimpleNode), "BLIHeapSimpleTree");
|
||||
heap->bufsize = std::max(1u, reserve_num);
|
||||
heap->tree = MEM_cnew_array<HeapSimpleNode>(heap->bufsize, "BLIHeapSimpleTree");
|
||||
return heap;
|
||||
}
|
||||
|
||||
@@ -178,7 +178,8 @@ void BLI_heapsimple_insert(HeapSimple *heap, float value, void *ptr)
|
||||
{
|
||||
if (UNLIKELY(heap->size >= heap->bufsize)) {
|
||||
heap->bufsize *= 2;
|
||||
heap->tree = MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree));
|
||||
heap->tree = static_cast<HeapSimpleNode *>(
|
||||
MEM_reallocN(heap->tree, heap->bufsize * sizeof(*heap->tree)));
|
||||
}
|
||||
|
||||
heapsimple_up(heap, heap->size++, value, ptr);
|
||||
@@ -900,8 +900,8 @@ BVHTree *BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
|
||||
numnodes = maxsize + implicit_needed_branches(tree_type, maxsize) + tree_type;
|
||||
|
||||
tree->nodes = MEM_cnew_array<BVHNode *>(size_t(numnodes), "BVHNodes");
|
||||
tree->nodebv = MEM_cnew_array<float>(size_t(axis * numnodes), "BVHNodeBV");
|
||||
tree->nodechild = MEM_cnew_array<BVHNode *>(size_t(tree_type * numnodes), "BVHNodeBV");
|
||||
tree->nodebv = MEM_cnew_array<float>(axis * size_t(numnodes), "BVHNodeBV");
|
||||
tree->nodechild = MEM_cnew_array<BVHNode *>(tree_type * size_t(numnodes), "BVHNodeBV");
|
||||
tree->nodearray = MEM_cnew_array<BVHNode>(size_t(numnodes), "BVHNodeArray");
|
||||
|
||||
if (UNLIKELY((!tree->nodes) || (!tree->nodebv) || (!tree->nodechild) || (!tree->nodearray))) {
|
||||
|
||||
@@ -10,14 +10,14 @@
|
||||
* For double linked lists see 'BLI_listbase.h'.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_memarena.h"
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
@@ -55,7 +55,7 @@ LinkNode *BLI_linklist_find(LinkNode *list, int index)
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinkNode *BLI_linklist_find_last(LinkNode *list)
|
||||
@@ -70,7 +70,7 @@ LinkNode *BLI_linklist_find_last(LinkNode *list)
|
||||
|
||||
void BLI_linklist_reverse(LinkNode **listp)
|
||||
{
|
||||
LinkNode *rhead = NULL, *cur = *listp;
|
||||
LinkNode *rhead = nullptr, *cur = *listp;
|
||||
|
||||
while (cur) {
|
||||
LinkNode *next = cur->next;
|
||||
@@ -86,7 +86,7 @@ void BLI_linklist_reverse(LinkNode **listp)
|
||||
|
||||
void BLI_linklist_move_item(LinkNode **listp, int curr_index, int new_index)
|
||||
{
|
||||
LinkNode *lnk, *lnk_psrc = NULL, *lnk_pdst = NULL;
|
||||
LinkNode *lnk, *lnk_psrc = nullptr, *lnk_pdst = nullptr;
|
||||
int i;
|
||||
|
||||
if (new_index == curr_index) {
|
||||
@@ -160,33 +160,33 @@ void BLI_linklist_prepend_nlink(LinkNode **listp, void *ptr, LinkNode *nlink)
|
||||
|
||||
void BLI_linklist_prepend(LinkNode **listp, void *ptr)
|
||||
{
|
||||
LinkNode *nlink = MEM_mallocN(sizeof(*nlink), __func__);
|
||||
LinkNode *nlink = static_cast<LinkNode *>(MEM_mallocN(sizeof(*nlink), __func__));
|
||||
BLI_linklist_prepend_nlink(listp, ptr, nlink);
|
||||
}
|
||||
|
||||
void BLI_linklist_prepend_arena(LinkNode **listp, void *ptr, MemArena *ma)
|
||||
{
|
||||
LinkNode *nlink = BLI_memarena_alloc(ma, sizeof(*nlink));
|
||||
LinkNode *nlink = BLI_memarena_alloc<LinkNode>(ma);
|
||||
BLI_linklist_prepend_nlink(listp, ptr, nlink);
|
||||
}
|
||||
|
||||
void BLI_linklist_prepend_pool(LinkNode **listp, void *ptr, BLI_mempool *mempool)
|
||||
{
|
||||
LinkNode *nlink = BLI_mempool_alloc(mempool);
|
||||
LinkNode *nlink = BLI_mempool_alloc<LinkNode>(mempool);
|
||||
BLI_linklist_prepend_nlink(listp, ptr, nlink);
|
||||
}
|
||||
|
||||
void BLI_linklist_append_nlink(LinkNodePair *list_pair, void *ptr, LinkNode *nlink)
|
||||
{
|
||||
nlink->link = ptr;
|
||||
nlink->next = NULL;
|
||||
nlink->next = nullptr;
|
||||
|
||||
if (list_pair->list) {
|
||||
BLI_assert((list_pair->last_node != NULL) && (list_pair->last_node->next == NULL));
|
||||
BLI_assert((list_pair->last_node != nullptr) && (list_pair->last_node->next == nullptr));
|
||||
list_pair->last_node->next = nlink;
|
||||
}
|
||||
else {
|
||||
BLI_assert(list_pair->last_node == NULL);
|
||||
BLI_assert(list_pair->last_node == nullptr);
|
||||
list_pair->list = nlink;
|
||||
}
|
||||
|
||||
@@ -195,27 +195,27 @@ void BLI_linklist_append_nlink(LinkNodePair *list_pair, void *ptr, LinkNode *nli
|
||||
|
||||
void BLI_linklist_append(LinkNodePair *list_pair, void *ptr)
|
||||
{
|
||||
LinkNode *nlink = MEM_mallocN(sizeof(*nlink), __func__);
|
||||
LinkNode *nlink = static_cast<LinkNode *>(MEM_mallocN(sizeof(*nlink), __func__));
|
||||
BLI_linklist_append_nlink(list_pair, ptr, nlink);
|
||||
}
|
||||
|
||||
void BLI_linklist_append_arena(LinkNodePair *list_pair, void *ptr, MemArena *ma)
|
||||
{
|
||||
LinkNode *nlink = BLI_memarena_alloc(ma, sizeof(*nlink));
|
||||
LinkNode *nlink = BLI_memarena_alloc<LinkNode>(ma);
|
||||
BLI_linklist_append_nlink(list_pair, ptr, nlink);
|
||||
}
|
||||
|
||||
void BLI_linklist_append_pool(LinkNodePair *list_pair, void *ptr, BLI_mempool *mempool)
|
||||
{
|
||||
LinkNode *nlink = BLI_mempool_alloc(mempool);
|
||||
LinkNode *nlink = BLI_mempool_alloc<LinkNode>(mempool);
|
||||
BLI_linklist_append_nlink(list_pair, ptr, nlink);
|
||||
}
|
||||
|
||||
void *BLI_linklist_pop(LinkNode **listp)
|
||||
{
|
||||
/* intentionally no NULL check */
|
||||
/* intentionally no nullptr check */
|
||||
void *link = (*listp)->link;
|
||||
void *next = (*listp)->next;
|
||||
LinkNode *next = (*listp)->next;
|
||||
|
||||
MEM_freeN(*listp);
|
||||
|
||||
@@ -225,9 +225,9 @@ void *BLI_linklist_pop(LinkNode **listp)
|
||||
|
||||
void *BLI_linklist_pop_pool(LinkNode **listp, BLI_mempool *mempool)
|
||||
{
|
||||
/* intentionally no NULL check */
|
||||
/* intentionally no nullptr check */
|
||||
void *link = (*listp)->link;
|
||||
void *next = (*listp)->next;
|
||||
LinkNode *next = (*listp)->next;
|
||||
|
||||
BLI_mempool_free(mempool, (*listp));
|
||||
|
||||
@@ -237,7 +237,7 @@ void *BLI_linklist_pop_pool(LinkNode **listp, BLI_mempool *mempool)
|
||||
|
||||
void BLI_linklist_insert_after(LinkNode **listp, void *ptr)
|
||||
{
|
||||
LinkNode *nlink = MEM_mallocN(sizeof(*nlink), __func__);
|
||||
LinkNode *nlink = MEM_cnew<LinkNode>(__func__);
|
||||
LinkNode *node = *listp;
|
||||
|
||||
nlink->link = ptr;
|
||||
@@ -247,7 +247,7 @@ void BLI_linklist_insert_after(LinkNode **listp, void *ptr)
|
||||
node->next = nlink;
|
||||
}
|
||||
else {
|
||||
nlink->next = NULL;
|
||||
nlink->next = nullptr;
|
||||
*listp = nlink;
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,6 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_linklist_lockfree.h"
|
||||
|
||||
#include "atomic_ops.h"
|
||||
@@ -16,16 +14,16 @@
|
||||
|
||||
void BLI_linklist_lockfree_init(LockfreeLinkList *list)
|
||||
{
|
||||
list->dummy_node.next = NULL;
|
||||
list->dummy_node.next = nullptr;
|
||||
list->head = list->tail = &list->dummy_node;
|
||||
}
|
||||
|
||||
void BLI_linklist_lockfree_free(LockfreeLinkList *list, LockfreeeLinkNodeFreeFP free_func)
|
||||
{
|
||||
if (free_func != NULL) {
|
||||
if (free_func != nullptr) {
|
||||
/* NOTE: We start from a first user-added node. */
|
||||
LockfreeLinkNode *node = list->head->next;
|
||||
while (node != NULL) {
|
||||
while (node != nullptr) {
|
||||
LockfreeLinkNode *node_next = node->next;
|
||||
free_func(node);
|
||||
node = node_next;
|
||||
@@ -50,10 +48,10 @@ void BLI_linklist_lockfree_insert(LockfreeLinkList *list, LockfreeLinkNode *node
|
||||
*/
|
||||
bool keep_working;
|
||||
LockfreeLinkNode *tail_node;
|
||||
node->next = NULL;
|
||||
node->next = nullptr;
|
||||
do {
|
||||
tail_node = list->tail;
|
||||
keep_working = (atomic_cas_ptr((void **)&tail_node->next, NULL, node) != NULL);
|
||||
keep_working = (atomic_cas_ptr((void **)&tail_node->next, nullptr, node) != nullptr);
|
||||
if (keep_working) {
|
||||
atomic_cas_ptr((void **)&list->tail, tail_node, tail_node->next);
|
||||
}
|
||||
@@ -14,8 +14,8 @@
|
||||
* \note Memory can't be freed during the arenas lifetime.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -52,7 +52,7 @@ struct MemArena {
|
||||
|
||||
static void memarena_buf_free_all(struct MemBuf *mb)
|
||||
{
|
||||
while (mb != NULL) {
|
||||
while (mb != nullptr) {
|
||||
struct MemBuf *mb_next = mb->next;
|
||||
|
||||
/* Unpoison memory because #MEM_freeN might overwrite it. */
|
||||
@@ -65,7 +65,7 @@ static void memarena_buf_free_all(struct MemBuf *mb)
|
||||
|
||||
MemArena *BLI_memarena_new(const size_t bufsize, const char *name)
|
||||
{
|
||||
MemArena *ma = MEM_callocN(sizeof(*ma), "memarena");
|
||||
MemArena *ma = MEM_cnew<MemArena>("memarena");
|
||||
ma->bufsize = bufsize;
|
||||
ma->align = 8;
|
||||
ma->name = name;
|
||||
@@ -77,12 +77,12 @@ MemArena *BLI_memarena_new(const size_t bufsize, const char *name)
|
||||
|
||||
void BLI_memarena_use_calloc(MemArena *ma)
|
||||
{
|
||||
ma->use_calloc = 1;
|
||||
ma->use_calloc = true;
|
||||
}
|
||||
|
||||
void BLI_memarena_use_malloc(MemArena *ma)
|
||||
{
|
||||
ma->use_calloc = 0;
|
||||
ma->use_calloc = false;
|
||||
}
|
||||
|
||||
void BLI_memarena_use_align(MemArena *ma, const size_t align)
|
||||
@@ -130,8 +130,8 @@ void *BLI_memarena_alloc(MemArena *ma, size_t size)
|
||||
ma->cursize = ma->bufsize;
|
||||
}
|
||||
|
||||
struct MemBuf *mb = (ma->use_calloc ? MEM_callocN : MEM_mallocN)(sizeof(*mb) + ma->cursize,
|
||||
ma->name);
|
||||
struct MemBuf *mb = static_cast<MemBuf *>(
|
||||
(ma->use_calloc ? MEM_callocN : MEM_mallocN)(sizeof(*mb) + ma->cursize, ma->name));
|
||||
ma->curbuf = mb->data;
|
||||
mb->next = ma->bufs;
|
||||
ma->bufs = mb;
|
||||
@@ -160,7 +160,7 @@ void *BLI_memarena_calloc(MemArena *ma, size_t size)
|
||||
BLI_assert(ma->use_calloc == false);
|
||||
|
||||
ptr = BLI_memarena_alloc(ma, size);
|
||||
BLI_assert(ptr != NULL);
|
||||
BLI_assert(ptr != nullptr);
|
||||
memset(ptr, 0, size);
|
||||
|
||||
return ptr;
|
||||
@@ -174,12 +174,12 @@ void BLI_memarena_merge(MemArena *ma_dst, MemArena *ma_src)
|
||||
BLI_assert(ma_dst->use_calloc == ma_src->use_calloc);
|
||||
BLI_assert(ma_dst->bufsize == ma_src->bufsize);
|
||||
|
||||
if (ma_src->bufs == NULL) {
|
||||
if (ma_src->bufs == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (UNLIKELY(ma_dst->bufs == NULL)) {
|
||||
BLI_assert(ma_dst->curbuf == NULL);
|
||||
if (UNLIKELY(ma_dst->bufs == nullptr)) {
|
||||
BLI_assert(ma_dst->curbuf == nullptr);
|
||||
ma_dst->bufs = ma_src->bufs;
|
||||
ma_dst->curbuf = ma_src->curbuf;
|
||||
ma_dst->cursize = ma_src->cursize;
|
||||
@@ -187,7 +187,7 @@ void BLI_memarena_merge(MemArena *ma_dst, MemArena *ma_src)
|
||||
else {
|
||||
/* Keep the 'ma_dst->curbuf' for simplicity.
|
||||
* Insert buffers after the first. */
|
||||
if (ma_dst->bufs->next != NULL) {
|
||||
if (ma_dst->bufs->next != nullptr) {
|
||||
/* Loop over `ma_src` instead of `ma_dst` since it's likely the destination is larger
|
||||
* when used for accumulating from multiple sources. */
|
||||
struct MemBuf *mb_src = ma_src->bufs;
|
||||
@@ -199,8 +199,8 @@ void BLI_memarena_merge(MemArena *ma_dst, MemArena *ma_src)
|
||||
ma_dst->bufs->next = ma_src->bufs;
|
||||
}
|
||||
|
||||
ma_src->bufs = NULL;
|
||||
ma_src->curbuf = NULL;
|
||||
ma_src->bufs = nullptr;
|
||||
ma_src->curbuf = nullptr;
|
||||
ma_src->cursize = 0;
|
||||
|
||||
VALGRIND_MOVE_MEMPOOL(ma_src, ma_dst);
|
||||
@@ -212,7 +212,7 @@ void BLI_memarena_clear(MemArena *ma)
|
||||
if (ma->bufs) {
|
||||
if (ma->bufs->next) {
|
||||
memarena_buf_free_all(ma->bufs->next);
|
||||
ma->bufs->next = NULL;
|
||||
ma->bufs->next = nullptr;
|
||||
}
|
||||
|
||||
const uchar *curbuf_prev = ma->curbuf;
|
||||
@@ -8,8 +8,9 @@
|
||||
* Dead simple, fast memory allocator for allocating many elements of the same size.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
@@ -46,14 +47,14 @@ BLI_memblock *BLI_memblock_create_ex(uint elem_size, uint chunk_size)
|
||||
{
|
||||
BLI_assert(elem_size < chunk_size);
|
||||
|
||||
BLI_memblock *mblk = MEM_mallocN(sizeof(BLI_memblock), "BLI_memblock");
|
||||
BLI_memblock *mblk = MEM_cnew<BLI_memblock>("BLI_memblock");
|
||||
mblk->elem_size = (int)elem_size;
|
||||
mblk->elem_next = 0;
|
||||
mblk->elem_last = -1;
|
||||
mblk->chunk_size = (int)chunk_size;
|
||||
mblk->chunk_len = CHUNK_LIST_SIZE;
|
||||
mblk->chunk_list = MEM_callocN(sizeof(void *) * (uint)mblk->chunk_len, "chunk list");
|
||||
mblk->chunk_list[0] = MEM_mallocN_aligned((uint)mblk->chunk_size, 32, "BLI_memblock chunk");
|
||||
mblk->chunk_list = MEM_cnew_array<void *>((size_t)mblk->chunk_len, "chunk list");
|
||||
mblk->chunk_list[0] = MEM_mallocN_aligned((size_t)mblk->chunk_size, 32, "BLI_memblock chunk");
|
||||
memset(mblk->chunk_list[0], 0x0, (uint)mblk->chunk_size);
|
||||
mblk->chunk_max_ofs = (mblk->chunk_size / mblk->elem_size) * mblk->elem_size;
|
||||
mblk->elem_next_ofs = 0;
|
||||
@@ -101,7 +102,8 @@ void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback)
|
||||
|
||||
if (UNLIKELY(last_used_chunk + 1 < mblk->chunk_len - CHUNK_LIST_SIZE)) {
|
||||
mblk->chunk_len -= CHUNK_LIST_SIZE;
|
||||
mblk->chunk_list = MEM_recallocN(mblk->chunk_list, sizeof(void *) * (uint)mblk->chunk_len);
|
||||
mblk->chunk_list = static_cast<void **>(
|
||||
MEM_recallocN(mblk->chunk_list, sizeof(void *) * (uint)mblk->chunk_len));
|
||||
}
|
||||
|
||||
mblk->elem_last = mblk->elem_next - 1;
|
||||
@@ -113,9 +115,7 @@ void BLI_memblock_clear(BLI_memblock *mblk, MemblockValFreeFP free_callback)
|
||||
void *BLI_memblock_alloc(BLI_memblock *mblk)
|
||||
{
|
||||
/* Bookkeeping. */
|
||||
if (mblk->elem_last < mblk->elem_next) {
|
||||
mblk->elem_last = mblk->elem_next;
|
||||
}
|
||||
mblk->elem_last = std::max(mblk->elem_last, mblk->elem_next);
|
||||
mblk->elem_next++;
|
||||
|
||||
void *ptr = (char *)(mblk->chunk_list[mblk->chunk_next]) + mblk->elem_next_ofs;
|
||||
@@ -128,10 +128,11 @@ void *BLI_memblock_alloc(BLI_memblock *mblk)
|
||||
|
||||
if (UNLIKELY(mblk->chunk_next >= mblk->chunk_len)) {
|
||||
mblk->chunk_len += CHUNK_LIST_SIZE;
|
||||
mblk->chunk_list = MEM_recallocN(mblk->chunk_list, sizeof(void *) * (uint)mblk->chunk_len);
|
||||
mblk->chunk_list = static_cast<void **>(
|
||||
MEM_recallocN(mblk->chunk_list, sizeof(void *) * (uint)mblk->chunk_len));
|
||||
}
|
||||
|
||||
if (UNLIKELY(mblk->chunk_list[mblk->chunk_next] == NULL)) {
|
||||
if (UNLIKELY(mblk->chunk_list[mblk->chunk_next] == nullptr)) {
|
||||
mblk->chunk_list[mblk->chunk_next] = MEM_mallocN_aligned(
|
||||
(uint)mblk->chunk_size, 32, "BLI_memblock chunk");
|
||||
memset(mblk->chunk_list[mblk->chunk_next], 0x0, (uint)mblk->chunk_size);
|
||||
@@ -155,7 +156,7 @@ void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter)
|
||||
void *BLI_memblock_iterstep(BLI_memblock_iter *iter)
|
||||
{
|
||||
if (iter->cur_index == iter->end_index) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
iter->cur_index++;
|
||||
@@ -25,8 +25,8 @@
|
||||
* but tests show this doesn't give noticeable speedup.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_asan.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@@ -39,8 +39,8 @@
|
||||
|
||||
/* TODO: Valgrind. */
|
||||
|
||||
typedef uintptr_t data_t;
|
||||
typedef intptr_t offset_t;
|
||||
using data_t = uintptr_t;
|
||||
using offset_t = intptr_t;
|
||||
|
||||
/* Write the chunk terminator on adding each element.
|
||||
* typically we rely on the 'count' to avoid iterating past the end. */
|
||||
@@ -52,12 +52,12 @@ typedef intptr_t offset_t;
|
||||
/* pad must be power of two */
|
||||
#define PADUP(num, pad) (((num) + ((pad)-1)) & ~((pad)-1))
|
||||
|
||||
typedef struct BLI_memiter_elem {
|
||||
struct BLI_memiter_elem {
|
||||
offset_t size;
|
||||
data_t data[0];
|
||||
} BLI_memiter_elem;
|
||||
};
|
||||
|
||||
typedef struct BLI_memiter_chunk {
|
||||
struct BLI_memiter_chunk {
|
||||
struct BLI_memiter_chunk *next;
|
||||
/**
|
||||
* internal format is:
|
||||
@@ -66,9 +66,9 @@ typedef struct BLI_memiter_chunk {
|
||||
* Where negative offset rewinds to the start.
|
||||
*/
|
||||
data_t data[0];
|
||||
} BLI_memiter_chunk;
|
||||
};
|
||||
|
||||
typedef struct BLI_memiter {
|
||||
struct BLI_memiter {
|
||||
/* A pointer to 'head' is needed so we can iterate in the order allocated. */
|
||||
BLI_memiter_chunk *head, *tail;
|
||||
data_t *data_curr;
|
||||
@@ -80,7 +80,7 @@ typedef struct BLI_memiter {
|
||||
#ifdef USE_TOTALLOC
|
||||
uint totalloc;
|
||||
#endif
|
||||
} BLI_memiter;
|
||||
};
|
||||
|
||||
BLI_INLINE uint data_offset_from_size(uint size)
|
||||
{
|
||||
@@ -99,10 +99,10 @@ static void memiter_set_rewind_offset(BLI_memiter *mi)
|
||||
|
||||
static void memiter_init(BLI_memiter *mi)
|
||||
{
|
||||
mi->head = NULL;
|
||||
mi->tail = NULL;
|
||||
mi->data_curr = NULL;
|
||||
mi->data_last = NULL;
|
||||
mi->head = nullptr;
|
||||
mi->tail = nullptr;
|
||||
mi->data_curr = nullptr;
|
||||
mi->data_last = nullptr;
|
||||
mi->count = 0;
|
||||
#ifdef USE_TOTALLOC
|
||||
mi->totalloc = 0;
|
||||
@@ -115,7 +115,7 @@ static void memiter_init(BLI_memiter *mi)
|
||||
|
||||
BLI_memiter *BLI_memiter_create(uint chunk_size_min)
|
||||
{
|
||||
BLI_memiter *mi = MEM_mallocN(sizeof(BLI_memiter), "BLI_memiter");
|
||||
BLI_memiter *mi = MEM_cnew<BLI_memiter>("BLI_memiter");
|
||||
memiter_init(mi);
|
||||
|
||||
/* Small values are used for tests to check for correctness,
|
||||
@@ -133,12 +133,12 @@ BLI_memiter *BLI_memiter_create(uint chunk_size_min)
|
||||
void *BLI_memiter_alloc(BLI_memiter *mi, uint elem_size)
|
||||
{
|
||||
const uint data_offset = data_offset_from_size(elem_size);
|
||||
data_t *data_curr_next = LIKELY(mi->data_curr) ? mi->data_curr + (1 + data_offset) : NULL;
|
||||
data_t *data_curr_next = LIKELY(mi->data_curr) ? mi->data_curr + (1 + data_offset) : nullptr;
|
||||
|
||||
if (UNLIKELY(mi->data_curr == NULL) || (data_curr_next > mi->data_last)) {
|
||||
if (UNLIKELY(mi->data_curr == nullptr) || (data_curr_next > mi->data_last)) {
|
||||
|
||||
#ifndef USE_TERMINATE_PARANOID
|
||||
if (mi->data_curr != NULL) {
|
||||
if (mi->data_curr != nullptr) {
|
||||
memiter_set_rewind_offset(mi);
|
||||
}
|
||||
#endif
|
||||
@@ -148,18 +148,18 @@ void *BLI_memiter_alloc(BLI_memiter *mi, uint elem_size)
|
||||
chunk_size_in_bytes = elem_size + (uint)sizeof(data_t[2]);
|
||||
}
|
||||
uint chunk_size = data_offset_from_size(chunk_size_in_bytes);
|
||||
BLI_memiter_chunk *chunk = MEM_mallocN(
|
||||
sizeof(BLI_memiter_chunk) + (chunk_size * sizeof(data_t)), "BLI_memiter_chunk");
|
||||
BLI_memiter_chunk *chunk = static_cast<BLI_memiter_chunk *>(MEM_mallocN(
|
||||
sizeof(BLI_memiter_chunk) + (chunk_size * sizeof(data_t)), "BLI_memiter_chunk"));
|
||||
|
||||
if (mi->head == NULL) {
|
||||
BLI_assert(mi->tail == NULL);
|
||||
if (mi->head == nullptr) {
|
||||
BLI_assert(mi->tail == nullptr);
|
||||
mi->head = chunk;
|
||||
}
|
||||
else {
|
||||
mi->tail->next = chunk;
|
||||
}
|
||||
mi->tail = chunk;
|
||||
chunk->next = NULL;
|
||||
chunk->next = nullptr;
|
||||
|
||||
mi->data_curr = chunk->data;
|
||||
mi->data_last = chunk->data + (chunk_size - 1);
|
||||
@@ -242,23 +242,23 @@ uint BLI_memiter_count(const BLI_memiter *mi)
|
||||
|
||||
void *BLI_memiter_elem_first(BLI_memiter *mi)
|
||||
{
|
||||
if (mi->head != NULL) {
|
||||
if (mi->head != nullptr) {
|
||||
BLI_memiter_chunk *chunk = mi->head;
|
||||
BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
|
||||
return elem->data;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
|
||||
{
|
||||
if (mi->head != NULL) {
|
||||
if (mi->head != nullptr) {
|
||||
BLI_memiter_chunk *chunk = mi->head;
|
||||
BLI_memiter_elem *elem = (BLI_memiter_elem *)chunk->data;
|
||||
*r_size = (uint)elem->size;
|
||||
return elem->data;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -266,7 +266,7 @@ void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Iterator API's
|
||||
*
|
||||
* \note We could loop over elements until a NULL chunk is found,
|
||||
* \note We could loop over elements until a nullptr chunk is found,
|
||||
* however this means every allocation needs to preemptively run
|
||||
* #memiter_set_rewind_offset (see #USE_TERMINATE_PARANOID).
|
||||
* Unless we have a call to finalize allocation (which complicates usage).
|
||||
@@ -276,7 +276,7 @@ void *BLI_memiter_elem_first_size(BLI_memiter *mi, uint *r_size)
|
||||
|
||||
void BLI_memiter_iter_init(BLI_memiter *mi, BLI_memiter_handle *iter)
|
||||
{
|
||||
iter->elem = mi->head ? (BLI_memiter_elem *)mi->head->data : NULL;
|
||||
iter->elem = mi->head ? (BLI_memiter_elem *)mi->head->data : nullptr;
|
||||
iter->elem_left = mi->count;
|
||||
}
|
||||
|
||||
@@ -290,8 +290,8 @@ BLI_INLINE void memiter_chunk_step(BLI_memiter_handle *iter)
|
||||
BLI_assert(iter->elem->size < 0);
|
||||
BLI_memiter_chunk *chunk = (BLI_memiter_chunk *)(((data_t *)iter->elem) + iter->elem->size);
|
||||
chunk = chunk->next;
|
||||
iter->elem = chunk ? (BLI_memiter_elem *)chunk->data : NULL;
|
||||
BLI_assert(iter->elem == NULL || iter->elem->size >= 0);
|
||||
iter->elem = chunk ? (BLI_memiter_elem *)chunk->data : nullptr;
|
||||
BLI_assert(iter->elem == nullptr || iter->elem->size >= 0);
|
||||
}
|
||||
|
||||
void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size)
|
||||
@@ -308,7 +308,7 @@ void *BLI_memiter_iter_step_size(BLI_memiter_handle *iter, uint *r_size)
|
||||
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
|
||||
return (void *)data;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
|
||||
@@ -324,7 +324,7 @@ void *BLI_memiter_iter_step(BLI_memiter_handle *iter)
|
||||
iter->elem = (BLI_memiter_elem *)&data[data_offset_from_size(size)];
|
||||
return (void *)data;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -14,8 +14,9 @@
|
||||
* (optionally when using the #BLI_MEMPOOL_ALLOW_ITER flag).
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "atomic_ops.h"
|
||||
|
||||
@@ -86,19 +87,19 @@ static bool mempool_debug_memset = false;
|
||||
*
|
||||
* Each element represents a block which BLI_mempool_alloc may return.
|
||||
*/
|
||||
typedef struct BLI_freenode {
|
||||
struct BLI_freenode {
|
||||
struct BLI_freenode *next;
|
||||
/** Used to identify this as a freed node. */
|
||||
intptr_t freeword;
|
||||
} BLI_freenode;
|
||||
};
|
||||
|
||||
/**
|
||||
* A chunk of memory in the mempool stored in
|
||||
* #BLI_mempool.chunks as a double linked list.
|
||||
*/
|
||||
typedef struct BLI_mempool_chunk {
|
||||
struct BLI_mempool_chunk {
|
||||
struct BLI_mempool_chunk *next;
|
||||
} BLI_mempool_chunk;
|
||||
};
|
||||
|
||||
/**
|
||||
* The mempool, stores and tracks memory \a chunks and elements within those chunks \a free.
|
||||
@@ -132,10 +133,11 @@ struct BLI_mempool {
|
||||
|
||||
#define MEMPOOL_ELEM_SIZE_MIN (sizeof(void *) * 2)
|
||||
|
||||
#define CHUNK_DATA(chunk) (CHECK_TYPE_INLINE(chunk, BLI_mempool_chunk *), (void *)((chunk) + 1))
|
||||
#define CHUNK_DATA(chunk) \
|
||||
((BLI_freenode *)(CHECK_TYPE_INLINE(chunk, BLI_mempool_chunk *), (void *)((chunk) + 1)))
|
||||
|
||||
#define NODE_STEP_NEXT(node) ((void *)((char *)(node) + esize))
|
||||
#define NODE_STEP_PREV(node) ((void *)((char *)(node)-esize))
|
||||
#define NODE_STEP_NEXT(node) ((BLI_freenode *)((char *)(node) + esize))
|
||||
#define NODE_STEP_PREV(node) ((BLI_freenode *)((char *)(node)-esize))
|
||||
|
||||
/** Extra bytes implicitly used for every chunk alloc. */
|
||||
#define CHUNK_OVERHEAD (uint)(MEM_SIZE_OVERHEAD + sizeof(BLI_mempool_chunk))
|
||||
@@ -192,7 +194,8 @@ BLI_INLINE uint mempool_maxchunks(const uint elem_num, const uint pchunk)
|
||||
|
||||
static BLI_mempool_chunk *mempool_chunk_alloc(const BLI_mempool *pool)
|
||||
{
|
||||
return MEM_mallocN(sizeof(BLI_mempool_chunk) + (size_t)pool->csize, "mempool chunk");
|
||||
return static_cast<BLI_mempool_chunk *>(
|
||||
MEM_mallocN(sizeof(BLI_mempool_chunk) + (size_t)pool->csize, "mempool chunk"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,14 +220,14 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
|
||||
pool->chunk_tail->next = mpchunk;
|
||||
}
|
||||
else {
|
||||
BLI_assert(pool->chunks == NULL);
|
||||
BLI_assert(pool->chunks == nullptr);
|
||||
pool->chunks = mpchunk;
|
||||
}
|
||||
|
||||
mpchunk->next = NULL;
|
||||
mpchunk->next = nullptr;
|
||||
pool->chunk_tail = mpchunk;
|
||||
|
||||
if (UNLIKELY(pool->free == NULL)) {
|
||||
if (UNLIKELY(pool->free == nullptr)) {
|
||||
pool->free = curnode;
|
||||
}
|
||||
|
||||
@@ -285,7 +288,7 @@ static BLI_freenode *mempool_chunk_add(BLI_mempool *pool,
|
||||
VALGRIND_MAKE_MEM_DEFINED(curnode, pool->esize - POISON_REDZONE_SIZE);
|
||||
#endif
|
||||
|
||||
curnode->next = NULL;
|
||||
curnode->next = nullptr;
|
||||
BLI_asan_poison(curnode, pool->esize);
|
||||
#ifdef WITH_MEM_VALGRIND
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(curnode, pool->esize);
|
||||
@@ -333,31 +336,29 @@ static void mempool_chunk_free_all(BLI_mempool_chunk *mpchunk, BLI_mempool *pool
|
||||
BLI_mempool *BLI_mempool_create(uint esize, uint elem_num, uint pchunk, uint flag)
|
||||
{
|
||||
BLI_mempool *pool;
|
||||
BLI_freenode *last_tail = NULL;
|
||||
BLI_freenode *last_tail = nullptr;
|
||||
uint i, maxchunks;
|
||||
|
||||
/* allocate the pool structure */
|
||||
pool = MEM_mallocN(sizeof(BLI_mempool), "memory pool");
|
||||
pool = MEM_cnew<BLI_mempool>("memory pool");
|
||||
|
||||
#ifdef WITH_ASAN
|
||||
BLI_mutex_init(&pool->mutex);
|
||||
#endif
|
||||
|
||||
/* set the elem size */
|
||||
if (esize < (int)MEMPOOL_ELEM_SIZE_MIN) {
|
||||
esize = (int)MEMPOOL_ELEM_SIZE_MIN;
|
||||
}
|
||||
esize = std::max(esize, (uint)MEMPOOL_ELEM_SIZE_MIN);
|
||||
|
||||
if (flag & BLI_MEMPOOL_ALLOW_ITER) {
|
||||
esize = MAX2(esize, (uint)sizeof(BLI_freenode));
|
||||
esize = std::max(esize, (uint)sizeof(BLI_freenode));
|
||||
}
|
||||
|
||||
esize += POISON_REDZONE_SIZE;
|
||||
|
||||
maxchunks = mempool_maxchunks(elem_num, pchunk);
|
||||
|
||||
pool->chunks = NULL;
|
||||
pool->chunk_tail = NULL;
|
||||
pool->chunks = nullptr;
|
||||
pool->chunk_tail = nullptr;
|
||||
pool->esize = esize;
|
||||
|
||||
/* Optimize chunk size to powers of 2, accounting for slop-space. */
|
||||
@@ -380,7 +381,7 @@ BLI_mempool *BLI_mempool_create(uint esize, uint elem_num, uint pchunk, uint fla
|
||||
|
||||
pool->pchunk = pchunk;
|
||||
pool->flag = flag;
|
||||
pool->free = NULL; /* mempool_chunk_add assigns */
|
||||
pool->free = nullptr; /* mempool_chunk_add assigns */
|
||||
pool->maxchunks = maxchunks;
|
||||
pool->totused = 0;
|
||||
|
||||
@@ -403,10 +404,10 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
|
||||
{
|
||||
BLI_freenode *free_pop;
|
||||
|
||||
if (UNLIKELY(pool->free == NULL)) {
|
||||
if (UNLIKELY(pool->free == nullptr)) {
|
||||
/* Need to allocate a new chunk. */
|
||||
BLI_mempool_chunk *mpchunk = mempool_chunk_alloc(pool);
|
||||
mempool_chunk_add(pool, mpchunk, NULL);
|
||||
mempool_chunk_add(pool, mpchunk, nullptr);
|
||||
}
|
||||
|
||||
free_pop = pool->free;
|
||||
@@ -424,7 +425,7 @@ void *BLI_mempool_alloc(BLI_mempool *pool)
|
||||
VALGRIND_MAKE_MEM_DEFINED(free_pop, pool->esize - POISON_REDZONE_SIZE);
|
||||
#endif
|
||||
|
||||
BLI_assert(pool->chunk_tail->next == NULL);
|
||||
BLI_assert(pool->chunk_tail->next == nullptr);
|
||||
|
||||
if (pool->flag & BLI_MEMPOOL_ALLOW_ITER) {
|
||||
free_pop->freeword = USEDWORD;
|
||||
@@ -456,7 +457,7 @@ void *BLI_mempool_calloc(BLI_mempool *pool)
|
||||
*/
|
||||
void BLI_mempool_free(BLI_mempool *pool, void *addr)
|
||||
{
|
||||
BLI_freenode *newhead = addr;
|
||||
BLI_freenode *newhead = static_cast<BLI_freenode *>(addr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
@@ -507,7 +508,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
|
||||
|
||||
first = pool->chunks;
|
||||
mempool_chunk_free_all(first->next, pool);
|
||||
first->next = NULL;
|
||||
first->next = nullptr;
|
||||
pool->chunk_tail = first;
|
||||
|
||||
/* Temporary allocation so VALGRIND doesn't complain when setting freed blocks 'next'. */
|
||||
@@ -533,7 +534,7 @@ void BLI_mempool_free(BLI_mempool *pool, void *addr)
|
||||
curnode = prev;
|
||||
|
||||
BLI_asan_unpoison(curnode, pool->esize - POISON_REDZONE_SIZE);
|
||||
curnode->next = NULL; /* terminate the list */
|
||||
curnode->next = nullptr; /* terminate the list */
|
||||
BLI_asan_poison(curnode, pool->esize);
|
||||
|
||||
#ifdef WITH_MEM_VALGRIND
|
||||
@@ -555,7 +556,7 @@ void *BLI_mempool_findelem(BLI_mempool *pool, uint index)
|
||||
|
||||
BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
|
||||
|
||||
if (index < (uint)pool->totused) {
|
||||
if (index < pool->totused) {
|
||||
/* We could have some faster mem chunk stepping code inline. */
|
||||
BLI_mempool_iter iter;
|
||||
void *elem;
|
||||
@@ -569,7 +570,7 @@ void *BLI_mempool_findelem(BLI_mempool *pool, uint index)
|
||||
}
|
||||
|
||||
mempool_asan_unlock(pool);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void BLI_mempool_as_array(BLI_mempool *pool, void *data)
|
||||
@@ -577,22 +578,23 @@ void BLI_mempool_as_array(BLI_mempool *pool, void *data)
|
||||
const uint esize = pool->esize - (uint)POISON_REDZONE_SIZE;
|
||||
BLI_mempool_iter iter;
|
||||
const char *elem;
|
||||
char *p = data;
|
||||
char *p = static_cast<char *>(data);
|
||||
|
||||
BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
|
||||
|
||||
mempool_asan_lock(pool);
|
||||
BLI_mempool_iternew(pool, &iter);
|
||||
while ((elem = BLI_mempool_iterstep(&iter))) {
|
||||
while ((elem = static_cast<const char *>(BLI_mempool_iterstep(&iter)))) {
|
||||
memcpy(p, elem, (size_t)esize);
|
||||
p = NODE_STEP_NEXT(p);
|
||||
p = reinterpret_cast<char *>(NODE_STEP_NEXT(p));
|
||||
}
|
||||
mempool_asan_unlock(pool);
|
||||
}
|
||||
|
||||
void *BLI_mempool_as_arrayN(BLI_mempool *pool, const char *allocstr)
|
||||
{
|
||||
char *data = MEM_malloc_arrayN((size_t)pool->totused, pool->esize, allocstr);
|
||||
char *data = static_cast<char *>(
|
||||
MEM_malloc_arrayN((size_t)pool->totused, pool->esize, allocstr));
|
||||
BLI_mempool_as_array(pool, data);
|
||||
return data;
|
||||
}
|
||||
@@ -609,15 +611,15 @@ void BLI_mempool_iternew(BLI_mempool *pool, BLI_mempool_iter *iter)
|
||||
static void mempool_threadsafe_iternew(BLI_mempool *pool, BLI_mempool_threadsafe_iter *ts_iter)
|
||||
{
|
||||
BLI_mempool_iternew(pool, &ts_iter->iter);
|
||||
ts_iter->curchunk_threaded_shared = NULL;
|
||||
ts_iter->curchunk_threaded_shared = nullptr;
|
||||
}
|
||||
|
||||
ParallelMempoolTaskData *mempool_iter_threadsafe_create(BLI_mempool *pool, const size_t iter_num)
|
||||
{
|
||||
BLI_assert(pool->flag & BLI_MEMPOOL_ALLOW_ITER);
|
||||
|
||||
ParallelMempoolTaskData *iter_arr = MEM_mallocN(sizeof(*iter_arr) * iter_num, __func__);
|
||||
BLI_mempool_chunk **curchunk_threaded_shared = MEM_mallocN(sizeof(void *), __func__);
|
||||
ParallelMempoolTaskData *iter_arr = MEM_cnew_array<ParallelMempoolTaskData>(iter_num, __func__);
|
||||
BLI_mempool_chunk **curchunk_threaded_shared = MEM_cnew<BLI_mempool_chunk *>(__func__);
|
||||
|
||||
mempool_threadsafe_iternew(pool, &iter_arr->ts_iter);
|
||||
|
||||
@@ -626,7 +628,7 @@ ParallelMempoolTaskData *mempool_iter_threadsafe_create(BLI_mempool *pool, const
|
||||
for (size_t i = 1; i < iter_num; i++) {
|
||||
iter_arr[i].ts_iter = iter_arr[0].ts_iter;
|
||||
*curchunk_threaded_shared = iter_arr[i].ts_iter.iter.curchunk =
|
||||
((*curchunk_threaded_shared) ? (*curchunk_threaded_shared)->next : NULL);
|
||||
((*curchunk_threaded_shared) ? (*curchunk_threaded_shared)->next : nullptr);
|
||||
}
|
||||
|
||||
return iter_arr;
|
||||
@@ -634,7 +636,7 @@ ParallelMempoolTaskData *mempool_iter_threadsafe_create(BLI_mempool *pool, const
|
||||
|
||||
void mempool_iter_threadsafe_destroy(ParallelMempoolTaskData *iter_arr)
|
||||
{
|
||||
BLI_assert(iter_arr->ts_iter.curchunk_threaded_shared != NULL);
|
||||
BLI_assert(iter_arr->ts_iter.curchunk_threaded_shared != nullptr);
|
||||
|
||||
MEM_freeN(iter_arr->ts_iter.curchunk_threaded_shared);
|
||||
MEM_freeN(iter_arr);
|
||||
@@ -645,9 +647,9 @@ void mempool_iter_threadsafe_destroy(ParallelMempoolTaskData *iter_arr)
|
||||
|
||||
static void *bli_mempool_iternext(BLI_mempool_iter *iter)
|
||||
{
|
||||
void *ret = NULL;
|
||||
void *ret = nullptr;
|
||||
|
||||
if (iter->curchunk == NULL || !iter->pool->totused) {
|
||||
if (iter->curchunk == nullptr || !iter->pool->totused) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -678,8 +680,8 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
|
||||
|
||||
void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
|
||||
{
|
||||
if (UNLIKELY(iter->curchunk == NULL)) {
|
||||
return NULL;
|
||||
if (UNLIKELY(iter->curchunk == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const uint esize = iter->pool->esize;
|
||||
@@ -699,12 +701,12 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
|
||||
else {
|
||||
iter->curindex = 0;
|
||||
iter->curchunk = iter->curchunk->next;
|
||||
if (UNLIKELY(iter->curchunk == NULL)) {
|
||||
if (UNLIKELY(iter->curchunk == nullptr)) {
|
||||
BLI_asan_unpoison(ret, iter->pool->esize - POISON_REDZONE_SIZE);
|
||||
# ifdef WITH_MEM_VALGRIND
|
||||
VALGRIND_MAKE_MEM_DEFINED(ret, iter->pool->esize - POISON_REDZONE_SIZE);
|
||||
# endif
|
||||
void *ret2 = (ret->freeword == FREEWORD) ? NULL : ret;
|
||||
void *ret2 = (ret->freeword == FREEWORD) ? nullptr : ret;
|
||||
|
||||
if (ret->freeword == FREEWORD) {
|
||||
BLI_asan_poison(ret, iter->pool->esize);
|
||||
@@ -725,8 +727,8 @@ void *BLI_mempool_iterstep(BLI_mempool_iter *iter)
|
||||
void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *ts_iter)
|
||||
{
|
||||
BLI_mempool_iter *iter = &ts_iter->iter;
|
||||
if (UNLIKELY(iter->curchunk == NULL)) {
|
||||
return NULL;
|
||||
if (UNLIKELY(iter->curchunk == nullptr)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
mempool_asan_lock(iter->pool);
|
||||
@@ -750,21 +752,22 @@ void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *ts_iter)
|
||||
|
||||
/* Begin unique to the `threadsafe` version of this function. */
|
||||
for (iter->curchunk = *ts_iter->curchunk_threaded_shared;
|
||||
(iter->curchunk != NULL) && (atomic_cas_ptr((void **)ts_iter->curchunk_threaded_shared,
|
||||
iter->curchunk,
|
||||
iter->curchunk->next) != iter->curchunk);
|
||||
(iter->curchunk != nullptr) &&
|
||||
(atomic_cas_ptr((void **)ts_iter->curchunk_threaded_shared,
|
||||
iter->curchunk,
|
||||
iter->curchunk->next) != iter->curchunk);
|
||||
iter->curchunk = *ts_iter->curchunk_threaded_shared)
|
||||
{
|
||||
/* pass. */
|
||||
}
|
||||
if (UNLIKELY(iter->curchunk == NULL)) {
|
||||
if (UNLIKELY(iter->curchunk == nullptr)) {
|
||||
if (ret->freeword == FREEWORD) {
|
||||
BLI_asan_poison(ret, esize);
|
||||
# ifdef WITH_MEM_VALGRIND
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(ret, iter->pool->esize);
|
||||
# endif
|
||||
mempool_asan_unlock(iter->pool);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
mempool_asan_unlock(iter->pool);
|
||||
return ret;
|
||||
@@ -772,14 +775,14 @@ void *mempool_iter_threadsafe_step(BLI_mempool_threadsafe_iter *ts_iter)
|
||||
/* End `threadsafe` exception. */
|
||||
|
||||
iter->curchunk = iter->curchunk->next;
|
||||
if (UNLIKELY(iter->curchunk == NULL)) {
|
||||
if (UNLIKELY(iter->curchunk == nullptr)) {
|
||||
if (ret->freeword == FREEWORD) {
|
||||
BLI_asan_poison(ret, iter->pool->esize);
|
||||
# ifdef WITH_MEM_VALGRIND
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(ret, iter->pool->esize);
|
||||
# endif
|
||||
mempool_asan_unlock(iter->pool);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
mempool_asan_unlock(iter->pool);
|
||||
return ret;
|
||||
@@ -812,7 +815,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int elem_num_reserve)
|
||||
uint maxchunks;
|
||||
|
||||
BLI_mempool_chunk *chunks_temp;
|
||||
BLI_freenode *last_tail = NULL;
|
||||
BLI_freenode *last_tail = nullptr;
|
||||
|
||||
#ifdef WITH_MEM_VALGRIND
|
||||
VALGRIND_DESTROY_MEMPOOL(pool);
|
||||
@@ -831,7 +834,7 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int elem_num_reserve)
|
||||
if (mpchunk && mpchunk->next) {
|
||||
/* terminate */
|
||||
mpchunk_next = mpchunk->next;
|
||||
mpchunk->next = NULL;
|
||||
mpchunk->next = nullptr;
|
||||
mpchunk = mpchunk_next;
|
||||
|
||||
do {
|
||||
@@ -841,11 +844,11 @@ void BLI_mempool_clear_ex(BLI_mempool *pool, const int elem_num_reserve)
|
||||
}
|
||||
|
||||
/* re-initialize */
|
||||
pool->free = NULL;
|
||||
pool->free = nullptr;
|
||||
pool->totused = 0;
|
||||
chunks_temp = pool->chunks;
|
||||
pool->chunks = NULL;
|
||||
pool->chunk_tail = NULL;
|
||||
pool->chunks = nullptr;
|
||||
pool->chunk_tail = nullptr;
|
||||
|
||||
while ((mpchunk = chunks_temp)) {
|
||||
chunks_temp = mpchunk->next;
|
||||
@@ -870,7 +873,7 @@ void BLI_mempool_destroy(BLI_mempool *pool)
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void BLI_mempool_set_memory_debug(void)
|
||||
void BLI_mempool_set_memory_debug()
|
||||
{
|
||||
mempool_debug_memset = true;
|
||||
}
|
||||
@@ -11,11 +11,11 @@
|
||||
#include "BLI_listbase.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef WIN32
|
||||
# include <signal.h>
|
||||
# include <stdlib.h>
|
||||
# include <csignal>
|
||||
# include <cstdlib>
|
||||
# include <sys/mman.h> /* For mmap. */
|
||||
# include <unistd.h> /* For read close. */
|
||||
#else
|
||||
@@ -56,7 +56,7 @@ static struct error_handler_data {
|
||||
ListBase open_mmaps;
|
||||
char configured;
|
||||
void (*next_handler)(int, siginfo_t *, void *);
|
||||
} error_handler = {0};
|
||||
} error_handler = {{nullptr}};
|
||||
|
||||
static void sigbus_handler(int sig, siginfo_t *siginfo, void *ptr)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ static void sigbus_handler(int sig, siginfo_t *siginfo, void *ptr)
|
||||
const char *error_addr = (const char *)siginfo->si_addr;
|
||||
/* Find the file that this error belongs to. */
|
||||
LISTBASE_FOREACH (LinkData *, link, &error_handler.open_mmaps) {
|
||||
BLI_mmap_file *file = link->data;
|
||||
BLI_mmap_file *file = static_cast<BLI_mmap_file *>(link->data);
|
||||
|
||||
/* Is the address where the error occurred in this file's mapped range? */
|
||||
if (error_addr >= file->memory && error_addr < file->memory + file->length) {
|
||||
@@ -94,10 +94,10 @@ static void sigbus_handler(int sig, siginfo_t *siginfo, void *ptr)
|
||||
}
|
||||
|
||||
/* Ensures that the error handler is set up and ready. */
|
||||
static bool sigbus_handler_setup(void)
|
||||
static bool sigbus_handler_setup()
|
||||
{
|
||||
if (!error_handler.configured) {
|
||||
struct sigaction newact = {0}, oldact = {0};
|
||||
struct sigaction newact = {{nullptr}}, oldact = {{nullptr}};
|
||||
|
||||
newact.sa_sigaction = sigbus_handler;
|
||||
newact.sa_flags = SA_SIGINFO;
|
||||
@@ -124,29 +124,30 @@ static void sigbus_handler_add(BLI_mmap_file *file)
|
||||
/* Removes a file from the list that the error handler checks. */
|
||||
static void sigbus_handler_remove(BLI_mmap_file *file)
|
||||
{
|
||||
LinkData *link = BLI_findptr(&error_handler.open_mmaps, file, offsetof(LinkData, data));
|
||||
LinkData *link = static_cast<LinkData *>(
|
||||
BLI_findptr(&error_handler.open_mmaps, file, offsetof(LinkData, data)));
|
||||
BLI_freelinkN(&error_handler.open_mmaps, link);
|
||||
}
|
||||
#endif
|
||||
|
||||
BLI_mmap_file *BLI_mmap_open(int fd)
|
||||
{
|
||||
void *memory, *handle = NULL;
|
||||
void *memory, *handle = nullptr;
|
||||
const size_t length = BLI_lseek(fd, 0, SEEK_END);
|
||||
if (UNLIKELY(length == (size_t)-1)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
/* Ensure that the SIGBUS handler is configured. */
|
||||
if (!sigbus_handler_setup()) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Map the given file to memory. */
|
||||
memory = mmap(NULL, length, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
memory = mmap(nullptr, length, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (memory == MAP_FAILED) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
/* Convert the POSIX-style file descriptor to a Windows handle. */
|
||||
@@ -154,20 +155,20 @@ BLI_mmap_file *BLI_mmap_open(int fd)
|
||||
/* Memory mapping on Windows is a two-step process - first we create a mapping,
|
||||
* then we create a view into that mapping.
|
||||
* In our case, one view that spans the entire file is enough. */
|
||||
handle = CreateFileMapping(file_handle, NULL, PAGE_READONLY, 0, 0, NULL);
|
||||
if (handle == NULL) {
|
||||
return NULL;
|
||||
handle = CreateFileMapping(file_handle, nullptr, PAGE_READONLY, 0, 0, nullptr);
|
||||
if (handle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
memory = MapViewOfFile(handle, FILE_MAP_READ, 0, 0, 0);
|
||||
if (memory == NULL) {
|
||||
if (memory == nullptr) {
|
||||
CloseHandle(handle);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Now that the mapping was successful, allocate memory and set up the BLI_mmap_file. */
|
||||
BLI_mmap_file *file = MEM_callocN(sizeof(BLI_mmap_file), __func__);
|
||||
file->memory = memory;
|
||||
BLI_mmap_file *file = MEM_cnew<BLI_mmap_file>(__func__);
|
||||
file->memory = static_cast<char *>(memory);
|
||||
file->handle = handle;
|
||||
file->length = length;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#define GET_TIME() BLI_time_now_seconds()
|
||||
|
||||
typedef struct TimedFunction {
|
||||
struct TimedFunction {
|
||||
struct TimedFunction *next, *prev;
|
||||
BLI_timer_func func;
|
||||
BLI_timer_data_free user_data_free;
|
||||
@@ -23,13 +23,13 @@ typedef struct TimedFunction {
|
||||
uintptr_t uuid;
|
||||
bool tag_removal;
|
||||
bool persistent;
|
||||
} TimedFunction;
|
||||
};
|
||||
|
||||
typedef struct TimerContainer {
|
||||
struct TimerContainer {
|
||||
ListBase funcs;
|
||||
} TimerContainer;
|
||||
};
|
||||
|
||||
static TimerContainer GlobalTimer = {{0}};
|
||||
static TimerContainer GlobalTimer = {{nullptr}};
|
||||
|
||||
void BLI_timer_register(uintptr_t uuid,
|
||||
BLI_timer_func func,
|
||||
@@ -38,7 +38,7 @@ void BLI_timer_register(uintptr_t uuid,
|
||||
double first_interval,
|
||||
bool persistent)
|
||||
{
|
||||
TimedFunction *timed_func = MEM_callocN(sizeof(TimedFunction), __func__);
|
||||
TimedFunction *timed_func = MEM_cnew<TimedFunction>(__func__);
|
||||
timed_func->func = func;
|
||||
timed_func->user_data_free = user_data_free;
|
||||
timed_func->user_data = user_data;
|
||||
@@ -54,7 +54,7 @@ static void clear_user_data(TimedFunction *timed_func)
|
||||
{
|
||||
if (timed_func->user_data_free) {
|
||||
timed_func->user_data_free(timed_func->uuid, timed_func->user_data);
|
||||
timed_func->user_data_free = NULL;
|
||||
timed_func->user_data_free = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ bool BLI_timer_is_registered(uintptr_t uuid)
|
||||
return false;
|
||||
}
|
||||
|
||||
static void execute_functions_if_necessary(void)
|
||||
static void execute_functions_if_necessary()
|
||||
{
|
||||
double current_time = GET_TIME();
|
||||
|
||||
@@ -103,9 +103,11 @@ static void execute_functions_if_necessary(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void remove_tagged_functions(void)
|
||||
static void remove_tagged_functions()
|
||||
{
|
||||
for (TimedFunction *timed_func = GlobalTimer.funcs.first; timed_func;) {
|
||||
for (TimedFunction *timed_func = static_cast<TimedFunction *>(GlobalTimer.funcs.first);
|
||||
timed_func;)
|
||||
{
|
||||
TimedFunction *next = timed_func->next;
|
||||
if (timed_func->tag_removal) {
|
||||
clear_user_data(timed_func);
|
||||
@@ -130,7 +132,7 @@ void BLI_timer_free(void)
|
||||
remove_tagged_functions();
|
||||
}
|
||||
|
||||
static void remove_non_persistent_functions(void)
|
||||
static void remove_non_persistent_functions()
|
||||
{
|
||||
LISTBASE_FOREACH (TimedFunction *, timed_func, &GlobalTimer.funcs) {
|
||||
if (!timed_func->persistent) {
|
||||
@@ -139,7 +141,7 @@ static void remove_non_persistent_functions(void)
|
||||
}
|
||||
}
|
||||
|
||||
void BLI_timer_on_file_load(void)
|
||||
void BLI_timer_on_file_load()
|
||||
{
|
||||
remove_non_persistent_functions();
|
||||
}
|
||||
@@ -93,8 +93,10 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_array_store.h" /* Own include. */
|
||||
#include "BLI_ghash.h" /* Only for #BLI_array_store_is_valid. */
|
||||
|
||||
@@ -172,7 +172,7 @@ int64_t count_booleans(const VArray<bool> &varray, const IndexMask &mask)
|
||||
const Span<bool> slice = span.slice(range);
|
||||
return init + std::count(slice.begin(), slice.end(), true);
|
||||
},
|
||||
std::plus<int64_t>());
|
||||
std::plus<>());
|
||||
}
|
||||
return threading::parallel_reduce(
|
||||
varray.index_range(),
|
||||
@@ -186,7 +186,7 @@ int64_t count_booleans(const VArray<bool> &varray, const IndexMask &mask)
|
||||
}
|
||||
return value;
|
||||
},
|
||||
std::plus<int64_t>());
|
||||
std::plus<>());
|
||||
}
|
||||
const CommonVArrayInfo info = varray.common_info();
|
||||
if (info.type == CommonVArrayInfo::Type::Single) {
|
||||
@@ -221,7 +221,7 @@ bool indices_are_range(Span<int> indices, IndexRange range)
|
||||
return is_range &&
|
||||
std::equal(local_indices.begin(), local_indices.end(), local_range.begin());
|
||||
},
|
||||
std::logical_and<bool>());
|
||||
std::logical_and<>());
|
||||
}
|
||||
|
||||
} // namespace blender::array_utils
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
* and only included for the cases where the performance is acceptable.
|
||||
* Use with care.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -29,7 +29,7 @@ void _bli_array_reverse(void *arr_v, uint arr_len, size_t arr_stride)
|
||||
const uint arr_stride_uint = (uint)arr_stride;
|
||||
const uint arr_half_stride = (arr_len / 2) * arr_stride_uint;
|
||||
uint i, i_end;
|
||||
char *arr = arr_v;
|
||||
char *arr = static_cast<char *>(arr_v);
|
||||
char *buf = BLI_array_alloca(buf, arr_stride);
|
||||
|
||||
for (i = 0, i_end = (arr_len - 1) * arr_stride_uint; i < arr_half_stride;
|
||||
@@ -43,7 +43,7 @@ void _bli_array_reverse(void *arr_v, uint arr_len, size_t arr_stride)
|
||||
|
||||
void _bli_array_wrap(void *arr_v, uint arr_len, size_t arr_stride, int dir)
|
||||
{
|
||||
char *arr = arr_v;
|
||||
char *arr = static_cast<char *>(arr_v);
|
||||
char *buf = BLI_array_alloca(buf, arr_stride);
|
||||
|
||||
if (dir == -1) {
|
||||
@@ -69,7 +69,7 @@ void _bli_array_permute(
|
||||
void *arr_orig;
|
||||
uint i;
|
||||
|
||||
if (arr_temp == NULL) {
|
||||
if (arr_temp == nullptr) {
|
||||
arr_orig = MEM_mallocN(len, __func__);
|
||||
}
|
||||
else {
|
||||
@@ -85,7 +85,7 @@ void _bli_array_permute(
|
||||
arr_stride);
|
||||
}
|
||||
|
||||
if (arr_temp == NULL) {
|
||||
if (arr_temp == nullptr) {
|
||||
MEM_freeN(arr_orig);
|
||||
}
|
||||
}
|
||||
@@ -139,9 +139,9 @@ int _bli_array_rfindindex(const void *arr, uint arr_len, size_t arr_stride, cons
|
||||
void _bli_array_binary_and(
|
||||
void *arr, const void *arr_a, const void *arr_b, uint arr_len, size_t arr_stride)
|
||||
{
|
||||
char *dst = arr;
|
||||
const char *src_a = arr_a;
|
||||
const char *src_b = arr_b;
|
||||
char *dst = static_cast<char *>(arr);
|
||||
const char *src_a = static_cast<const char *>(arr_a);
|
||||
const char *src_b = static_cast<const char *>(arr_b);
|
||||
|
||||
size_t i = arr_stride * arr_len;
|
||||
while (i--) {
|
||||
@@ -152,9 +152,9 @@ void _bli_array_binary_and(
|
||||
void _bli_array_binary_or(
|
||||
void *arr, const void *arr_a, const void *arr_b, uint arr_len, size_t arr_stride)
|
||||
{
|
||||
char *dst = arr;
|
||||
const char *src_a = arr_a;
|
||||
const char *src_b = arr_b;
|
||||
char *dst = static_cast<char *>(arr);
|
||||
const char *src_a = static_cast<const char *>(arr_a);
|
||||
const char *src_b = static_cast<const char *>(arr_b);
|
||||
|
||||
size_t i = arr_stride * arr_len;
|
||||
while (i--) {
|
||||
@@ -197,7 +197,7 @@ bool _bli_array_iter_span(const void *arr,
|
||||
test_prev = test_fn(item_prev, user_data);
|
||||
}
|
||||
else {
|
||||
item_prev = NULL;
|
||||
item_prev = nullptr;
|
||||
i_curr = 0;
|
||||
test_prev = false;
|
||||
}
|
||||
@@ -294,7 +294,7 @@ bool _bli_array_iter_spiral_square(const void *arr_v,
|
||||
BLI_assert(center[0] >= 0 && center[1] >= 0 && center[0] < arr_shape[0] &&
|
||||
center[1] < arr_shape[1]);
|
||||
|
||||
const char *arr = arr_v;
|
||||
const char *arr = static_cast<const char *>(arr_v);
|
||||
const int stride[2] = {arr_shape[0] * (int)elem_size, (int)elem_size};
|
||||
|
||||
/* Test center first. */
|
||||
@@ -24,11 +24,6 @@
|
||||
* It will be cleared much more often than graph's one.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#include "BLI_heap_simple.h"
|
||||
@@ -50,8 +45,8 @@ void BLI_astar_node_link_add(BLI_AStarGraph *as_graph,
|
||||
void *custom_data)
|
||||
{
|
||||
MemArena *mem = as_graph->mem;
|
||||
BLI_AStarGNLink *link = BLI_memarena_alloc(mem, sizeof(*link));
|
||||
LinkData *ld = BLI_memarena_alloc(mem, sizeof(*ld) * 2);
|
||||
BLI_AStarGNLink *link = BLI_memarena_alloc<BLI_AStarGNLink>(mem);
|
||||
LinkData *ld = BLI_memarena_alloc<LinkData>(mem, 2);
|
||||
|
||||
link->nodes[0] = node1_index;
|
||||
link->nodes[1] = node2_index;
|
||||
@@ -76,21 +71,21 @@ void BLI_astar_solution_init(BLI_AStarGraph *as_graph,
|
||||
MemArena *mem = as_solution->mem;
|
||||
size_t node_num = (size_t)as_graph->node_num;
|
||||
|
||||
if (mem == NULL) {
|
||||
if (mem == nullptr) {
|
||||
mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
|
||||
as_solution->mem = mem;
|
||||
}
|
||||
/* else memarena should be cleared */
|
||||
|
||||
as_solution->steps = 0;
|
||||
as_solution->prev_nodes = BLI_memarena_alloc(mem, sizeof(*as_solution->prev_nodes) * node_num);
|
||||
as_solution->prev_links = BLI_memarena_alloc(mem, sizeof(*as_solution->prev_links) * node_num);
|
||||
as_solution->prev_nodes = BLI_memarena_alloc<int>(mem, node_num);
|
||||
as_solution->prev_links = BLI_memarena_alloc<BLI_AStarGNLink *>(mem, node_num);
|
||||
|
||||
as_solution->custom_data = custom_data;
|
||||
|
||||
as_solution->done_nodes = BLI_BITMAP_NEW_MEMARENA(mem, node_num);
|
||||
as_solution->g_costs = BLI_memarena_alloc(mem, sizeof(*as_solution->g_costs) * node_num);
|
||||
as_solution->g_steps = BLI_memarena_alloc(mem, sizeof(*as_solution->g_steps) * node_num);
|
||||
as_solution->g_costs = BLI_memarena_alloc<float>(mem, node_num);
|
||||
as_solution->g_steps = BLI_memarena_alloc<int>(mem, node_num);
|
||||
}
|
||||
|
||||
void BLI_astar_solution_clear(BLI_AStarSolution *as_solution)
|
||||
@@ -100,21 +95,21 @@ void BLI_astar_solution_clear(BLI_AStarSolution *as_solution)
|
||||
}
|
||||
|
||||
as_solution->steps = 0;
|
||||
as_solution->prev_nodes = NULL;
|
||||
as_solution->prev_links = NULL;
|
||||
as_solution->prev_nodes = nullptr;
|
||||
as_solution->prev_links = nullptr;
|
||||
|
||||
as_solution->custom_data = NULL;
|
||||
as_solution->custom_data = nullptr;
|
||||
|
||||
as_solution->done_nodes = NULL;
|
||||
as_solution->g_costs = NULL;
|
||||
as_solution->g_steps = NULL;
|
||||
as_solution->done_nodes = nullptr;
|
||||
as_solution->g_costs = nullptr;
|
||||
as_solution->g_steps = nullptr;
|
||||
}
|
||||
|
||||
void BLI_astar_solution_free(BLI_AStarSolution *as_solution)
|
||||
{
|
||||
if (as_solution->mem) {
|
||||
BLI_memarena_free(as_solution->mem);
|
||||
as_solution->mem = NULL;
|
||||
as_solution->mem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,14 +117,14 @@ void BLI_astar_graph_init(BLI_AStarGraph *as_graph, const int node_num, void *cu
|
||||
{
|
||||
MemArena *mem = as_graph->mem;
|
||||
|
||||
if (mem == NULL) {
|
||||
if (mem == nullptr) {
|
||||
mem = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__);
|
||||
as_graph->mem = mem;
|
||||
}
|
||||
/* else memarena should be cleared */
|
||||
|
||||
as_graph->node_num = node_num;
|
||||
as_graph->nodes = BLI_memarena_calloc(mem, sizeof(*as_graph->nodes) * (size_t)node_num);
|
||||
as_graph->nodes = BLI_memarena_calloc<BLI_AStarGNode>(mem, (size_t)node_num);
|
||||
|
||||
as_graph->custom_data = custom_data;
|
||||
}
|
||||
@@ -138,7 +133,7 @@ void BLI_astar_graph_free(BLI_AStarGraph *as_graph)
|
||||
{
|
||||
if (as_graph->mem) {
|
||||
BLI_memarena_free(as_graph->mem);
|
||||
as_graph->mem = NULL;
|
||||
as_graph->mem = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,9 +164,10 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
|
||||
}
|
||||
|
||||
todo_nodes = BLI_heapsimple_new();
|
||||
BLI_heapsimple_insert(todo_nodes,
|
||||
f_cost_cb(as_graph, r_solution, NULL, -1, node_index_src, node_index_dst),
|
||||
POINTER_FROM_INT(node_index_src));
|
||||
BLI_heapsimple_insert(
|
||||
todo_nodes,
|
||||
f_cost_cb(as_graph, r_solution, nullptr, -1, node_index_src, node_index_dst),
|
||||
POINTER_FROM_INT(node_index_src));
|
||||
|
||||
while (!BLI_heapsimple_is_empty(todo_nodes)) {
|
||||
const int node_curr_idx = POINTER_AS_INT(BLI_heapsimple_pop_min(todo_nodes));
|
||||
@@ -193,14 +189,14 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
|
||||
/* Success! Path found... */
|
||||
r_solution->steps = g_steps[node_curr_idx] + 1;
|
||||
|
||||
BLI_heapsimple_free(todo_nodes, NULL);
|
||||
BLI_heapsimple_free(todo_nodes, nullptr);
|
||||
return true;
|
||||
}
|
||||
|
||||
BLI_BITMAP_ENABLE(done_nodes, node_curr_idx);
|
||||
|
||||
for (ld = node_curr->neighbor_links.first; ld; ld = ld->next) {
|
||||
BLI_AStarGNLink *link = ld->data;
|
||||
for (ld = static_cast<LinkData *>(node_curr->neighbor_links.first); ld; ld = ld->next) {
|
||||
BLI_AStarGNLink *link = static_cast<BLI_AStarGNLink *>(ld->data);
|
||||
const int node_next_idx = BLI_astar_node_link_other_node(link, node_curr_idx);
|
||||
|
||||
if (!BLI_BITMAP_TEST(done_nodes, node_next_idx)) {
|
||||
@@ -222,6 +218,6 @@ bool BLI_astar_graph_solve(BLI_AStarGraph *as_graph,
|
||||
}
|
||||
}
|
||||
|
||||
BLI_heapsimple_free(todo_nodes, NULL);
|
||||
BLI_heapsimple_free(todo_nodes, nullptr);
|
||||
return false;
|
||||
}
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "BLI_bit_bool_conversion.hh"
|
||||
#include "BLI_simd.hh"
|
||||
#include "BLI_timeit.hh"
|
||||
|
||||
namespace blender::bits {
|
||||
|
||||
|
||||
@@ -8,12 +8,11 @@
|
||||
* Utility functions for variable size bit-masks.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_bitmap.h"
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
void BLI_bitmap_set_all(BLI_bitmap *bitmap, bool set, size_t bits)
|
||||
{
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <math.h> /* for fabsf */
|
||||
#include <stdlib.h> /* for qsort */
|
||||
#include <cmath> /* for fabsf */
|
||||
#include <cstdlib> /* for qsort */
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
/* BoxPacker for backing 2D rectangles into a square
|
||||
*
|
||||
* The defined Below are for internal use only */
|
||||
typedef struct BoxVert {
|
||||
struct BoxVert {
|
||||
float x;
|
||||
float y;
|
||||
|
||||
@@ -56,7 +56,7 @@ typedef struct BoxVert {
|
||||
float bias;
|
||||
int _pad2;
|
||||
#endif
|
||||
} BoxVert;
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wpadded"
|
||||
@@ -203,7 +203,8 @@ static void vert_bias_update(BoxVert *v)
|
||||
/* qsort function - sort largest to smallest */
|
||||
static int box_areasort(const void *p1, const void *p2)
|
||||
{
|
||||
const BoxPack *b1 = p1, *b2 = p2;
|
||||
const BoxPack *b1 = static_cast<const BoxPack *>(p1);
|
||||
const BoxPack *b2 = static_cast<const BoxPack *>(p2);
|
||||
const float a1 = box_area(b1);
|
||||
const float a2 = box_area(b2);
|
||||
|
||||
@@ -228,7 +229,7 @@ struct VertSortContext {
|
||||
|
||||
static int vertex_sort(const void *p1, const void *p2, void *vs_ctx_p)
|
||||
{
|
||||
const struct VertSortContext *vs_ctx = vs_ctx_p;
|
||||
const VertSortContext *vs_ctx = static_cast<const VertSortContext *>(vs_ctx_p);
|
||||
const BoxVert *v1, *v2;
|
||||
float a1, a2;
|
||||
|
||||
@@ -279,7 +280,7 @@ void BLI_box_pack_2d(
|
||||
BoxPack *box, *box_test; /* Current box and another for intersection tests. */
|
||||
BoxVert *vert; /* The current vert. */
|
||||
|
||||
struct VertSortContext vs_ctx;
|
||||
VertSortContext vs_ctx;
|
||||
|
||||
if (!len) {
|
||||
*r_tot_x = tot_x;
|
||||
@@ -294,15 +295,16 @@ void BLI_box_pack_2d(
|
||||
}
|
||||
|
||||
/* Add verts to the boxes, these are only used internally. */
|
||||
vert = MEM_mallocN(sizeof(BoxVert[4]) * (size_t)len, "BoxPack Verts");
|
||||
vertex_pack_indices = MEM_mallocN(sizeof(int[3]) * (size_t)len, "BoxPack Indices");
|
||||
vert = static_cast<BoxVert *>(MEM_mallocN(sizeof(BoxVert[4]) * (size_t)len, "BoxPack Verts"));
|
||||
vertex_pack_indices = static_cast<uint *>(
|
||||
MEM_mallocN(sizeof(int[3]) * (size_t)len, "BoxPack Indices"));
|
||||
|
||||
vs_ctx.vertarray = vert;
|
||||
|
||||
for (box = boxarray, box_index = 0, i = 0; box_index < len; box_index++, box++) {
|
||||
|
||||
vert->blb = vert->brb = vert->tlb = vert->isect_cache[0] = vert->isect_cache[1] =
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = nullptr;
|
||||
vert->free = CORNERFLAGS & ~TRF;
|
||||
vert->trb = box;
|
||||
vert->used = false;
|
||||
@@ -310,7 +312,7 @@ void BLI_box_pack_2d(
|
||||
box->v[BL] = vert++;
|
||||
|
||||
vert->trb = vert->brb = vert->tlb = vert->isect_cache[0] = vert->isect_cache[1] =
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = nullptr;
|
||||
vert->free = CORNERFLAGS & ~BLF;
|
||||
vert->blb = box;
|
||||
vert->used = false;
|
||||
@@ -318,7 +320,7 @@ void BLI_box_pack_2d(
|
||||
box->v[TR] = vert++;
|
||||
|
||||
vert->trb = vert->blb = vert->tlb = vert->isect_cache[0] = vert->isect_cache[1] =
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = nullptr;
|
||||
vert->free = CORNERFLAGS & ~BRF;
|
||||
vert->brb = box;
|
||||
vert->used = false;
|
||||
@@ -326,14 +328,14 @@ void BLI_box_pack_2d(
|
||||
box->v[TL] = vert++;
|
||||
|
||||
vert->trb = vert->blb = vert->brb = vert->isect_cache[0] = vert->isect_cache[1] =
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = NULL;
|
||||
vert->isect_cache[2] = vert->isect_cache[3] = nullptr;
|
||||
vert->free = CORNERFLAGS & ~TLF;
|
||||
vert->tlb = box;
|
||||
vert->used = false;
|
||||
vert->index = i++;
|
||||
box->v[BR] = vert++;
|
||||
}
|
||||
vert = NULL;
|
||||
vert = nullptr;
|
||||
|
||||
/* Pack the First box!
|
||||
* then enter the main box-packing loop */
|
||||
@@ -654,7 +656,7 @@ void BLI_box_pack_2d(
|
||||
* touched anymore but accessing the pointers would crash blender */
|
||||
for (box_index = 0; box_index < len; box_index++) {
|
||||
box = boxarray + box_index;
|
||||
box->v[0] = box->v[1] = box->v[2] = box->v[3] = NULL;
|
||||
box->v[0] = box->v[1] = box->v[2] = box->v[3] = nullptr;
|
||||
}
|
||||
MEM_freeN(vertex_pack_indices);
|
||||
MEM_freeN(vs_ctx.vertarray);
|
||||
@@ -662,8 +664,8 @@ void BLI_box_pack_2d(
|
||||
|
||||
void BLI_box_pack_2d_fixedarea(ListBase *boxes, int width, int height, ListBase *packed)
|
||||
{
|
||||
ListBase spaces = {NULL};
|
||||
FixedSizeBoxPack *full_rect = MEM_callocN(sizeof(FixedSizeBoxPack), __func__);
|
||||
ListBase spaces = {nullptr};
|
||||
FixedSizeBoxPack *full_rect = MEM_cnew<FixedSizeBoxPack>(__func__);
|
||||
full_rect->w = width;
|
||||
full_rect->h = height;
|
||||
|
||||
@@ -725,7 +727,7 @@ void BLI_box_pack_2d_fixedarea(ListBase *boxes, int width, int height, ListBase
|
||||
|
||||
/* Perform split. This space becomes the larger space,
|
||||
* while the new smaller space is inserted _before_ it. */
|
||||
FixedSizeBoxPack *new_space = MEM_callocN(sizeof(FixedSizeBoxPack), __func__);
|
||||
FixedSizeBoxPack *new_space = MEM_cnew<FixedSizeBoxPack>(__func__);
|
||||
if (area_hsplit_large > area_vsplit_large) {
|
||||
new_space->x = space->x + box->w;
|
||||
new_space->y = space->y;
|
||||
@@ -29,7 +29,7 @@
|
||||
* it was declared in.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include "BLI_array.hh"
|
||||
#include "BLI_linklist.h"
|
||||
#include "BLI_math_boolean.hh"
|
||||
#include "BLI_math_mpq.hh"
|
||||
#include "BLI_math_vector_mpq_types.hh"
|
||||
#include "BLI_set.hh"
|
||||
#include "BLI_task.hh"
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "BLI_endian_switch.h"
|
||||
#include "BLI_sys_types.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
void BLI_endian_switch_int16_array(short *val, const int size)
|
||||
{
|
||||
@@ -26,14 +26,13 @@
|
||||
* The implementation has no global state and can be used multi-threaded.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fenv.h>
|
||||
#include <float.h>
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cctype>
|
||||
#include <cfenv>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <variant>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -41,6 +40,7 @@
|
||||
#include "BLI_expr_pylike_eval.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma fenv_access(on)
|
||||
@@ -50,7 +50,7 @@
|
||||
/** \name Internal Types
|
||||
* \{ */
|
||||
|
||||
typedef enum eOpCode {
|
||||
enum eOpCode {
|
||||
/* Double constant: (-> dval). */
|
||||
OPCODE_CONST,
|
||||
/* 1 argument function call: (a -> func1(a)). */
|
||||
@@ -75,13 +75,13 @@ typedef enum eOpCode {
|
||||
OPCODE_JMP_AND,
|
||||
/* For comparison chaining: (a b -> 0 JUMP) IF NOT func2(a,b) ELSE (a b -> b). */
|
||||
OPCODE_CMP_CHAIN,
|
||||
} eOpCode;
|
||||
};
|
||||
|
||||
typedef double (*UnaryOpFunc)(double);
|
||||
typedef double (*BinaryOpFunc)(double, double);
|
||||
typedef double (*TernaryOpFunc)(double, double, double);
|
||||
using UnaryOpFunc = double (*)(double);
|
||||
using BinaryOpFunc = double (*)(double, double);
|
||||
using TernaryOpFunc = double (*)(double, double, double);
|
||||
|
||||
typedef struct ExprOp {
|
||||
struct ExprOp {
|
||||
eOpCode opcode;
|
||||
|
||||
int jmp_offset;
|
||||
@@ -94,13 +94,11 @@ typedef struct ExprOp {
|
||||
BinaryOpFunc func2;
|
||||
TernaryOpFunc func3;
|
||||
} arg;
|
||||
} ExprOp;
|
||||
};
|
||||
|
||||
struct ExprPyLike_Parsed {
|
||||
int ops_count;
|
||||
blender::Vector<ExprOp> ops;
|
||||
int max_stack;
|
||||
|
||||
ExprOp ops[];
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -111,30 +109,28 @@ struct ExprPyLike_Parsed {
|
||||
|
||||
void BLI_expr_pylike_free(ExprPyLike_Parsed *expr)
|
||||
{
|
||||
if (expr != NULL) {
|
||||
MEM_freeN(expr);
|
||||
}
|
||||
MEM_delete(expr);
|
||||
}
|
||||
|
||||
bool BLI_expr_pylike_is_valid(const ExprPyLike_Parsed *expr)
|
||||
{
|
||||
return expr != NULL && expr->ops_count > 0;
|
||||
return expr != nullptr && expr->ops.size() > 0;
|
||||
}
|
||||
|
||||
bool BLI_expr_pylike_is_constant(const ExprPyLike_Parsed *expr)
|
||||
{
|
||||
return expr != NULL && expr->ops_count == 1 && expr->ops[0].opcode == OPCODE_CONST;
|
||||
return expr != nullptr && expr->ops.size() == 1 && expr->ops[0].opcode == OPCODE_CONST;
|
||||
}
|
||||
|
||||
bool BLI_expr_pylike_is_using_param(const ExprPyLike_Parsed *expr, int index)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (expr == NULL) {
|
||||
if (expr == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (i = 0; i < expr->ops_count; i++) {
|
||||
for (i = 0; i < expr->ops.size(); i++) {
|
||||
if (expr->ops[i].opcode == OPCODE_PARAMETER && expr->ops[i].arg.ival == index) {
|
||||
return true;
|
||||
}
|
||||
@@ -172,12 +168,12 @@ eExprPyLike_EvalStatus BLI_expr_pylike_eval(ExprPyLike_Parsed *expr,
|
||||
double *stack = BLI_array_alloca(stack, expr->max_stack);
|
||||
|
||||
/* Evaluate expression. */
|
||||
ExprOp *ops = expr->ops;
|
||||
ExprOp *ops = expr->ops.data();
|
||||
int sp = 0, pc;
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
|
||||
for (pc = 0; pc >= 0 && pc < expr->ops_count; pc++) {
|
||||
for (pc = 0; pc >= 0 && pc < expr->ops.size(); pc++) {
|
||||
switch (ops[pc].opcode) {
|
||||
/* Arithmetic */
|
||||
case OPCODE_CONST:
|
||||
@@ -256,7 +252,7 @@ eExprPyLike_EvalStatus BLI_expr_pylike_eval(ExprPyLike_Parsed *expr,
|
||||
}
|
||||
}
|
||||
|
||||
FAIL_IF(sp != 1 || pc != expr->ops_count);
|
||||
FAIL_IF(sp != 1 || pc != expr->ops.size());
|
||||
|
||||
#undef FAIL_IF
|
||||
|
||||
@@ -376,19 +372,35 @@ static double op_ge(double a, double b)
|
||||
return a >= b ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
typedef struct BuiltinConstDef {
|
||||
struct BuiltinConstDef {
|
||||
const char *name;
|
||||
double value;
|
||||
} BuiltinConstDef;
|
||||
};
|
||||
|
||||
static BuiltinConstDef builtin_consts[] = {
|
||||
{"pi", M_PI}, {"True", 1.0}, {"False", 0.0}, {NULL, 0.0}};
|
||||
{"pi", M_PI}, {"True", 1.0}, {"False", 0.0}, {nullptr, 0.0}};
|
||||
|
||||
typedef struct BuiltinOpDef {
|
||||
struct BuiltinOpDef {
|
||||
const char *name;
|
||||
eOpCode op;
|
||||
void *funcptr;
|
||||
} BuiltinOpDef;
|
||||
std::variant<UnaryOpFunc, BinaryOpFunc, TernaryOpFunc> funcptr;
|
||||
|
||||
/* Returns the required argument count of the given function call code. */
|
||||
int arg_count()
|
||||
{
|
||||
if (std::holds_alternative<UnaryOpFunc>(funcptr)) {
|
||||
return 1;
|
||||
}
|
||||
if (std::holds_alternative<BinaryOpFunc>(funcptr)) {
|
||||
return 2;
|
||||
}
|
||||
if (std::holds_alternative<TernaryOpFunc>(funcptr)) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
BLI_assert_msg(0, "unexpected function pointer");
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* Prevent MSVC from inlining calls to ceil/floor so the table below can get a function pointer to
|
||||
@@ -398,33 +410,33 @@ typedef struct BuiltinOpDef {
|
||||
#endif
|
||||
|
||||
static BuiltinOpDef builtin_ops[] = {
|
||||
{"radians", OPCODE_FUNC1, op_radians},
|
||||
{"degrees", OPCODE_FUNC1, op_degrees},
|
||||
{"abs", OPCODE_FUNC1, fabs},
|
||||
{"fabs", OPCODE_FUNC1, fabs},
|
||||
{"floor", OPCODE_FUNC1, floor},
|
||||
{"ceil", OPCODE_FUNC1, ceil},
|
||||
{"trunc", OPCODE_FUNC1, trunc},
|
||||
{"round", OPCODE_FUNC1, round},
|
||||
{"int", OPCODE_FUNC1, trunc},
|
||||
{"sin", OPCODE_FUNC1, sin},
|
||||
{"cos", OPCODE_FUNC1, cos},
|
||||
{"tan", OPCODE_FUNC1, tan},
|
||||
{"asin", OPCODE_FUNC1, asin},
|
||||
{"acos", OPCODE_FUNC1, acos},
|
||||
{"atan", OPCODE_FUNC1, atan},
|
||||
{"atan2", OPCODE_FUNC2, atan2},
|
||||
{"exp", OPCODE_FUNC1, exp},
|
||||
{"log", OPCODE_FUNC1, log},
|
||||
{"log", OPCODE_FUNC2, op_log2},
|
||||
{"sqrt", OPCODE_FUNC1, sqrt},
|
||||
{"pow", OPCODE_FUNC2, pow},
|
||||
{"fmod", OPCODE_FUNC2, fmod},
|
||||
{"lerp", OPCODE_FUNC3, op_lerp},
|
||||
{"clamp", OPCODE_FUNC1, op_clamp},
|
||||
{"clamp", OPCODE_FUNC3, op_clamp3},
|
||||
{"smoothstep", OPCODE_FUNC3, op_smoothstep},
|
||||
{NULL, OPCODE_CONST, NULL},
|
||||
{"radians", UnaryOpFunc(op_radians)},
|
||||
{"degrees", UnaryOpFunc(op_degrees)},
|
||||
{"abs", UnaryOpFunc(fabs)},
|
||||
{"fabs", UnaryOpFunc(fabs)},
|
||||
{"floor", UnaryOpFunc(floor)},
|
||||
{"ceil", UnaryOpFunc(ceil)},
|
||||
{"trunc", UnaryOpFunc(trunc)},
|
||||
{"round", UnaryOpFunc(round)},
|
||||
{"int", UnaryOpFunc(trunc)},
|
||||
{"sin", UnaryOpFunc(sin)},
|
||||
{"cos", UnaryOpFunc(cos)},
|
||||
{"tan", UnaryOpFunc(tan)},
|
||||
{"asin", UnaryOpFunc(asin)},
|
||||
{"acos", UnaryOpFunc(acos)},
|
||||
{"atan", UnaryOpFunc(atan)},
|
||||
{"atan2", BinaryOpFunc(atan2)},
|
||||
{"exp", UnaryOpFunc(exp)},
|
||||
{"log", UnaryOpFunc(log)},
|
||||
{"log", BinaryOpFunc(op_log2)},
|
||||
{"sqrt", UnaryOpFunc(sqrt)},
|
||||
{"pow", BinaryOpFunc(pow)},
|
||||
{"fmod", BinaryOpFunc(fmod)},
|
||||
{"lerp", TernaryOpFunc(op_lerp)},
|
||||
{"clamp", UnaryOpFunc(op_clamp)},
|
||||
{"clamp", TernaryOpFunc(op_clamp3)},
|
||||
{"smoothstep", TernaryOpFunc(op_smoothstep)},
|
||||
{nullptr},
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -458,10 +470,10 @@ static BuiltinOpDef builtin_ops[] = {
|
||||
static const char *token_eq_characters = "!=><";
|
||||
static const char *token_characters = "~`!@#$%^&*+-=/\\?:;<>(){}[]|.,\"'";
|
||||
|
||||
typedef struct KeywordTokenDef {
|
||||
struct KeywordTokenDef {
|
||||
const char *name;
|
||||
short token;
|
||||
} KeywordTokenDef;
|
||||
};
|
||||
|
||||
static KeywordTokenDef keyword_list[] = {
|
||||
{"and", TOKEN_AND},
|
||||
@@ -469,42 +481,30 @@ static KeywordTokenDef keyword_list[] = {
|
||||
{"not", TOKEN_NOT},
|
||||
{"if", TOKEN_IF},
|
||||
{"else", TOKEN_ELSE},
|
||||
{NULL, TOKEN_ID},
|
||||
{nullptr, TOKEN_ID},
|
||||
};
|
||||
|
||||
typedef struct ExprParseState {
|
||||
int param_names_len;
|
||||
const char **param_names;
|
||||
struct ExprParseState {
|
||||
int param_names_len = 0;
|
||||
const char **param_names = nullptr;
|
||||
|
||||
/* Original expression */
|
||||
const char *expr;
|
||||
const char *cur;
|
||||
const char *expr = nullptr;
|
||||
const char *cur = nullptr;
|
||||
|
||||
/* Current token */
|
||||
short token;
|
||||
char *tokenbuf;
|
||||
double tokenval;
|
||||
short token = 0;
|
||||
blender::Vector<char> tokenbuf;
|
||||
double tokenval = 0.0;
|
||||
|
||||
/* Opcode buffer */
|
||||
int ops_count, max_ops, last_jmp;
|
||||
ExprOp *ops;
|
||||
int last_jmp = 0;
|
||||
blender::Vector<ExprOp> ops;
|
||||
|
||||
/* Stack space requirement tracking */
|
||||
int stack_ptr, max_stack;
|
||||
} ExprParseState;
|
||||
|
||||
/* Reserve space for the specified number of operations in the buffer. */
|
||||
static ExprOp *parse_alloc_ops(ExprParseState *state, int count)
|
||||
{
|
||||
if (state->ops_count + count > state->max_ops) {
|
||||
state->max_ops = power_of_2_max_i(state->ops_count + count);
|
||||
state->ops = MEM_reallocN(state->ops, state->max_ops * sizeof(ExprOp));
|
||||
}
|
||||
|
||||
ExprOp *op = &state->ops[state->ops_count];
|
||||
state->ops_count += count;
|
||||
return op;
|
||||
}
|
||||
int stack_ptr = 0;
|
||||
int max_stack = 0;
|
||||
};
|
||||
|
||||
/* Add one operation and track stack usage. */
|
||||
static ExprOp *parse_add_op(ExprParseState *state, eOpCode code, int stack_delta)
|
||||
@@ -515,117 +515,95 @@ static ExprOp *parse_add_op(ExprParseState *state, eOpCode code, int stack_delta
|
||||
CLAMP_MIN(state->max_stack, state->stack_ptr);
|
||||
|
||||
/* allocate the new instruction */
|
||||
ExprOp *op = parse_alloc_ops(state, 1);
|
||||
memset(op, 0, sizeof(ExprOp));
|
||||
op->opcode = code;
|
||||
return op;
|
||||
ExprOp op{code};
|
||||
state->ops.append(op);
|
||||
return &state->ops.last();
|
||||
}
|
||||
|
||||
/* Add one jump operation and return an index for parse_set_jump. */
|
||||
static int parse_add_jump(ExprParseState *state, eOpCode code)
|
||||
{
|
||||
parse_add_op(state, code, -1);
|
||||
return state->last_jmp = state->ops_count;
|
||||
return state->last_jmp = state->ops.size();
|
||||
}
|
||||
|
||||
/* Set the jump offset in a previously added jump operation. */
|
||||
static void parse_set_jump(ExprParseState *state, int jump)
|
||||
{
|
||||
state->last_jmp = state->ops_count;
|
||||
state->ops[jump - 1].jmp_offset = state->ops_count - jump;
|
||||
}
|
||||
|
||||
/* Returns the required argument count of the given function call code. */
|
||||
static int opcode_arg_count(eOpCode code)
|
||||
{
|
||||
switch (code) {
|
||||
case OPCODE_FUNC1:
|
||||
return 1;
|
||||
case OPCODE_FUNC2:
|
||||
return 2;
|
||||
case OPCODE_FUNC3:
|
||||
return 3;
|
||||
default:
|
||||
BLI_assert_msg(0, "unexpected opcode");
|
||||
return -1;
|
||||
}
|
||||
state->last_jmp = state->ops.size();
|
||||
state->ops[jump - 1].jmp_offset = state->ops.size() - jump;
|
||||
}
|
||||
|
||||
/* Add a function call operation, applying constant folding when possible. */
|
||||
static bool parse_add_func(ExprParseState *state, eOpCode code, int args, void *funcptr)
|
||||
static bool parse_add_func(ExprParseState *state,
|
||||
std::variant<UnaryOpFunc, BinaryOpFunc, TernaryOpFunc> funcptr)
|
||||
{
|
||||
ExprOp *prev_ops = &state->ops[state->ops_count];
|
||||
int jmp_gap = state->ops_count - state->last_jmp;
|
||||
ExprOp *prev_ops = state->ops.end();
|
||||
int jmp_gap = state->ops.size() - state->last_jmp;
|
||||
|
||||
feclearexcept(FE_ALL_EXCEPT);
|
||||
|
||||
switch (code) {
|
||||
case OPCODE_FUNC1:
|
||||
CHECK_ERROR(args == 1);
|
||||
if (std::holds_alternative<UnaryOpFunc>(funcptr)) {
|
||||
UnaryOpFunc func = std::get<UnaryOpFunc>(funcptr);
|
||||
|
||||
if (jmp_gap >= 1 && prev_ops[-1].opcode == OPCODE_CONST) {
|
||||
UnaryOpFunc func = funcptr;
|
||||
if (jmp_gap >= 1 && prev_ops[-1].opcode == OPCODE_CONST) {
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(prev_ops[-1].arg.dval);
|
||||
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(prev_ops[-1].arg.dval);
|
||||
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-1].arg.dval = result;
|
||||
return true;
|
||||
}
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-1].arg.dval = result;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OPCODE_FUNC2:
|
||||
CHECK_ERROR(args == 2);
|
||||
parse_add_op(state, OPCODE_FUNC1, 0)->arg.func1 = func;
|
||||
}
|
||||
else if (std::holds_alternative<BinaryOpFunc>(funcptr)) {
|
||||
BinaryOpFunc func = std::get<BinaryOpFunc>(funcptr);
|
||||
|
||||
if (jmp_gap >= 2 && prev_ops[-2].opcode == OPCODE_CONST &&
|
||||
prev_ops[-1].opcode == OPCODE_CONST)
|
||||
{
|
||||
BinaryOpFunc func = funcptr;
|
||||
if (jmp_gap >= 2 && prev_ops[-2].opcode == OPCODE_CONST && prev_ops[-1].opcode == OPCODE_CONST)
|
||||
{
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(prev_ops[-2].arg.dval, prev_ops[-1].arg.dval);
|
||||
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(prev_ops[-2].arg.dval, prev_ops[-1].arg.dval);
|
||||
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-2].arg.dval = result;
|
||||
state->ops_count--;
|
||||
state->stack_ptr--;
|
||||
return true;
|
||||
}
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-2].arg.dval = result;
|
||||
state->ops.resize(state->ops.size() - 1);
|
||||
state->stack_ptr--;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case OPCODE_FUNC3:
|
||||
CHECK_ERROR(args == 3);
|
||||
parse_add_op(state, OPCODE_FUNC2, -1)->arg.func2 = func;
|
||||
}
|
||||
else if (std::holds_alternative<TernaryOpFunc>(funcptr)) {
|
||||
TernaryOpFunc func = std::get<TernaryOpFunc>(funcptr);
|
||||
|
||||
if (jmp_gap >= 3 && prev_ops[-3].opcode == OPCODE_CONST &&
|
||||
prev_ops[-2].opcode == OPCODE_CONST && prev_ops[-1].opcode == OPCODE_CONST)
|
||||
{
|
||||
TernaryOpFunc func = funcptr;
|
||||
if (jmp_gap >= 3 && prev_ops[-3].opcode == OPCODE_CONST &&
|
||||
prev_ops[-2].opcode == OPCODE_CONST && prev_ops[-1].opcode == OPCODE_CONST)
|
||||
{
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(
|
||||
prev_ops[-3].arg.dval, prev_ops[-2].arg.dval, prev_ops[-1].arg.dval);
|
||||
|
||||
/* volatile because some compilers overly aggressive optimize this call out.
|
||||
* see D6012 for details. */
|
||||
volatile double result = func(
|
||||
prev_ops[-3].arg.dval, prev_ops[-2].arg.dval, prev_ops[-1].arg.dval);
|
||||
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-3].arg.dval = result;
|
||||
state->ops_count -= 2;
|
||||
state->stack_ptr -= 2;
|
||||
return true;
|
||||
}
|
||||
if (fetestexcept(FE_DIVBYZERO | FE_INVALID) == 0) {
|
||||
prev_ops[-3].arg.dval = result;
|
||||
state->ops.resize(state->ops.size() - 2);
|
||||
state->stack_ptr -= 2;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BLI_assert(false);
|
||||
return false;
|
||||
parse_add_op(state, OPCODE_FUNC3, -2)->arg.func3 = func;
|
||||
}
|
||||
else {
|
||||
BLI_assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
parse_add_op(state, code, 1 - args)->arg.ptr = funcptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -645,7 +623,7 @@ static bool parse_next_token(ExprParseState *state)
|
||||
|
||||
/* Floating point numbers. */
|
||||
if (isdigit(*state->cur) || (state->cur[0] == '.' && isdigit(state->cur[1]))) {
|
||||
char *end, *out = state->tokenbuf;
|
||||
char *end, *out = state->tokenbuf.data();
|
||||
bool is_float = false;
|
||||
|
||||
while (isdigit(*state->cur)) {
|
||||
@@ -680,7 +658,7 @@ static bool parse_next_token(ExprParseState *state)
|
||||
|
||||
/* Forbid C-style octal constants. */
|
||||
if (!is_float && state->tokenbuf[0] == '0') {
|
||||
for (char *p = state->tokenbuf + 1; *p; p++) {
|
||||
for (char *p = state->tokenbuf.data() + 1; *p; p++) {
|
||||
if (*p != '0') {
|
||||
return false;
|
||||
}
|
||||
@@ -688,7 +666,7 @@ static bool parse_next_token(ExprParseState *state)
|
||||
}
|
||||
|
||||
state->token = TOKEN_NUMBER;
|
||||
state->tokenval = strtod(state->tokenbuf, &end);
|
||||
state->tokenval = strtod(state->tokenbuf.data(), &end);
|
||||
return (end == out);
|
||||
}
|
||||
|
||||
@@ -707,7 +685,7 @@ static bool parse_next_token(ExprParseState *state)
|
||||
|
||||
/* Identifiers */
|
||||
if (isalpha(*state->cur) || ELEM(*state->cur, '_')) {
|
||||
char *out = state->tokenbuf;
|
||||
char *out = state->tokenbuf.data();
|
||||
|
||||
while (isalnum(*state->cur) || ELEM(*state->cur, '_')) {
|
||||
*out++ = *state->cur++;
|
||||
@@ -716,7 +694,7 @@ static bool parse_next_token(ExprParseState *state)
|
||||
*out = 0;
|
||||
|
||||
for (int i = 0; keyword_list[i].name; i++) {
|
||||
if (STREQ(state->tokenbuf, keyword_list[i].name)) {
|
||||
if (STREQ(state->tokenbuf.data(), keyword_list[i].name)) {
|
||||
state->token = keyword_list[i].token;
|
||||
return true;
|
||||
}
|
||||
@@ -781,7 +759,7 @@ static bool parse_unary(ExprParseState *state)
|
||||
|
||||
case '-':
|
||||
CHECK_ERROR(parse_next_token(state) && parse_unary(state));
|
||||
parse_add_func(state, OPCODE_FUNC1, 1, op_negate);
|
||||
parse_add_func(state, op_negate);
|
||||
return true;
|
||||
|
||||
case '(':
|
||||
@@ -796,7 +774,7 @@ static bool parse_unary(ExprParseState *state)
|
||||
/* Parameters: search in reverse order in case of duplicate names -
|
||||
* the last one should win. */
|
||||
for (i = state->param_names_len - 1; i >= 0; i--) {
|
||||
if (STREQ(state->tokenbuf, state->param_names[i])) {
|
||||
if (STREQ(state->tokenbuf.data(), state->param_names[i])) {
|
||||
parse_add_op(state, OPCODE_PARAMETER, 1)->arg.ival = i;
|
||||
return parse_next_token(state);
|
||||
}
|
||||
@@ -804,7 +782,7 @@ static bool parse_unary(ExprParseState *state)
|
||||
|
||||
/* Ordinary builtin constants. */
|
||||
for (i = 0; builtin_consts[i].name; i++) {
|
||||
if (STREQ(state->tokenbuf, builtin_consts[i].name)) {
|
||||
if (STREQ(state->tokenbuf.data(), builtin_consts[i].name)) {
|
||||
parse_add_op(state, OPCODE_CONST, 1)->arg.dval = builtin_consts[i].value;
|
||||
return parse_next_token(state);
|
||||
}
|
||||
@@ -812,13 +790,13 @@ static bool parse_unary(ExprParseState *state)
|
||||
|
||||
/* Ordinary builtin functions. */
|
||||
for (i = 0; builtin_ops[i].name; i++) {
|
||||
if (STREQ(state->tokenbuf, builtin_ops[i].name)) {
|
||||
if (STREQ(state->tokenbuf.data(), builtin_ops[i].name)) {
|
||||
int args = parse_function_args(state);
|
||||
|
||||
/* Search for other arg count versions if necessary. */
|
||||
if (args != opcode_arg_count(builtin_ops[i].op)) {
|
||||
if (args != builtin_ops[i].arg_count()) {
|
||||
for (int j = i + 1; builtin_ops[j].name; j++) {
|
||||
if (opcode_arg_count(builtin_ops[j].op) == args &&
|
||||
if (builtin_ops[j].arg_count() == args &&
|
||||
STREQ(builtin_ops[j].name, builtin_ops[i].name))
|
||||
{
|
||||
i = j;
|
||||
@@ -827,12 +805,14 @@ static bool parse_unary(ExprParseState *state)
|
||||
}
|
||||
}
|
||||
|
||||
return parse_add_func(state, builtin_ops[i].op, args, builtin_ops[i].funcptr);
|
||||
CHECK_ERROR(builtin_ops[i].name && builtin_ops[i].arg_count() == args);
|
||||
|
||||
return parse_add_func(state, builtin_ops[i].funcptr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Specially supported functions. */
|
||||
if (STREQ(state->tokenbuf, "min")) {
|
||||
if (STREQ(state->tokenbuf.data(), "min")) {
|
||||
int count = parse_function_args(state);
|
||||
CHECK_ERROR(count > 0);
|
||||
|
||||
@@ -840,7 +820,7 @@ static bool parse_unary(ExprParseState *state)
|
||||
return true;
|
||||
}
|
||||
|
||||
if (STREQ(state->tokenbuf, "max")) {
|
||||
if (STREQ(state->tokenbuf.data(), "max")) {
|
||||
int count = parse_function_args(state);
|
||||
CHECK_ERROR(count > 0);
|
||||
|
||||
@@ -863,12 +843,12 @@ static bool parse_mul(ExprParseState *state)
|
||||
switch (state->token) {
|
||||
case '*':
|
||||
CHECK_ERROR(parse_next_token(state) && parse_unary(state));
|
||||
parse_add_func(state, OPCODE_FUNC2, 2, op_mul);
|
||||
parse_add_func(state, op_mul);
|
||||
break;
|
||||
|
||||
case '/':
|
||||
CHECK_ERROR(parse_next_token(state) && parse_unary(state));
|
||||
parse_add_func(state, OPCODE_FUNC2, 2, op_div);
|
||||
parse_add_func(state, op_div);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -885,12 +865,12 @@ static bool parse_add(ExprParseState *state)
|
||||
switch (state->token) {
|
||||
case '+':
|
||||
CHECK_ERROR(parse_next_token(state) && parse_mul(state));
|
||||
parse_add_func(state, OPCODE_FUNC2, 2, op_add);
|
||||
parse_add_func(state, op_add);
|
||||
break;
|
||||
|
||||
case '-':
|
||||
CHECK_ERROR(parse_next_token(state) && parse_mul(state));
|
||||
parse_add_func(state, OPCODE_FUNC2, 2, op_sub);
|
||||
parse_add_func(state, op_sub);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -915,7 +895,7 @@ static BinaryOpFunc parse_get_cmp_func(short token)
|
||||
case TOKEN_LE:
|
||||
return op_le;
|
||||
default:
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,7 +905,7 @@ static bool parse_cmp_chain(ExprParseState *state, BinaryOpFunc cur_func)
|
||||
|
||||
if (next_func) {
|
||||
parse_add_op(state, OPCODE_CMP_CHAIN, -1)->arg.func2 = cur_func;
|
||||
int jump = state->last_jmp = state->ops_count;
|
||||
int jump = state->last_jmp = state->ops.size();
|
||||
|
||||
CHECK_ERROR(parse_next_token(state) && parse_add(state));
|
||||
CHECK_ERROR(parse_cmp_chain(state, next_func));
|
||||
@@ -933,7 +913,7 @@ static bool parse_cmp_chain(ExprParseState *state, BinaryOpFunc cur_func)
|
||||
parse_set_jump(state, jump);
|
||||
}
|
||||
else {
|
||||
parse_add_func(state, OPCODE_FUNC2, 2, cur_func);
|
||||
parse_add_func(state, cur_func);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -958,7 +938,7 @@ static bool parse_not(ExprParseState *state)
|
||||
{
|
||||
if (state->token == TOKEN_NOT) {
|
||||
CHECK_ERROR(parse_next_token(state) && parse_not(state));
|
||||
parse_add_func(state, OPCODE_FUNC1, 1, op_not);
|
||||
parse_add_func(state, op_not);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -999,35 +979,36 @@ static bool parse_expr(ExprParseState *state)
|
||||
{
|
||||
/* Temporarily set the constant expression evaluation barrier */
|
||||
int prev_last_jmp = state->last_jmp;
|
||||
int start = state->last_jmp = state->ops_count;
|
||||
int start = state->last_jmp = state->ops.size();
|
||||
|
||||
CHECK_ERROR(parse_or(state));
|
||||
|
||||
if (state->token == TOKEN_IF) {
|
||||
/* Ternary IF expression in python requires swapping the
|
||||
* main body with condition, so stash the body opcodes. */
|
||||
int size = state->ops_count - start;
|
||||
int bytes = size * sizeof(ExprOp);
|
||||
const int size = state->ops.size() - start;
|
||||
|
||||
ExprOp *body = MEM_mallocN(bytes, "driver if body");
|
||||
memcpy(body, state->ops + start, bytes);
|
||||
blender::Vector<ExprOp> body(size);
|
||||
std::copy_n(state->ops.data() + start, size, body.data());
|
||||
|
||||
state->last_jmp = state->ops_count = start;
|
||||
state->ops.resize(start);
|
||||
state->last_jmp = start;
|
||||
state->stack_ptr--;
|
||||
|
||||
/* Parse condition. */
|
||||
if (!parse_next_token(state) || !parse_or(state) || state->token != TOKEN_ELSE ||
|
||||
!parse_next_token(state))
|
||||
{
|
||||
MEM_freeN(body);
|
||||
return false;
|
||||
}
|
||||
|
||||
int jmp_else = parse_add_jump(state, OPCODE_JMP_ELSE);
|
||||
|
||||
/* Add body back. */
|
||||
memcpy(parse_alloc_ops(state, size), body, bytes);
|
||||
MEM_freeN(body);
|
||||
const size_t body_offset = state->ops.size();
|
||||
state->ops.resize(body_offset + size);
|
||||
std::copy_n(body.data(), size, state->ops.data() + body_offset);
|
||||
body.clear_and_shrink();
|
||||
|
||||
state->stack_ptr++;
|
||||
|
||||
@@ -1060,39 +1041,27 @@ ExprPyLike_Parsed *BLI_expr_pylike_parse(const char *expression,
|
||||
{
|
||||
/* Prepare the parser state. */
|
||||
ExprParseState state;
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
state.cur = state.expr = expression;
|
||||
|
||||
state.param_names_len = param_names_len;
|
||||
state.param_names = param_names;
|
||||
|
||||
state.tokenbuf = MEM_mallocN(strlen(expression) + 1, __func__);
|
||||
|
||||
state.max_ops = 16;
|
||||
state.ops = MEM_mallocN(state.max_ops * sizeof(ExprOp), __func__);
|
||||
state.tokenbuf.resize(strlen(expression) + 1);
|
||||
|
||||
/* Parse the expression. */
|
||||
ExprPyLike_Parsed *expr;
|
||||
ExprPyLike_Parsed *expr = MEM_new<ExprPyLike_Parsed>("ExprPyLike_Parsed(empty)");
|
||||
|
||||
if (parse_next_token(&state) && parse_expr(&state) && state.token == 0) {
|
||||
BLI_assert(state.stack_ptr == 1);
|
||||
|
||||
int bytesize = sizeof(ExprPyLike_Parsed) + state.ops_count * sizeof(ExprOp);
|
||||
|
||||
expr = MEM_mallocN(bytesize, "ExprPyLike_Parsed");
|
||||
expr->ops_count = state.ops_count;
|
||||
expr->max_stack = state.max_stack;
|
||||
|
||||
memcpy(expr->ops, state.ops, state.ops_count * sizeof(ExprOp));
|
||||
expr->ops = std::move(state.ops);
|
||||
}
|
||||
else {
|
||||
/* Always return a non-NULL object so that parse failure can be cached. */
|
||||
expr = MEM_callocN(sizeof(ExprPyLike_Parsed), "ExprPyLike_Parsed(empty)");
|
||||
/* Always return a non-nullptr object so that parse failure can be cached. */
|
||||
}
|
||||
|
||||
MEM_freeN(state.tokenbuf);
|
||||
MEM_freeN(state.ops);
|
||||
return expr;
|
||||
}
|
||||
|
||||
@@ -562,9 +562,9 @@ void *BLI_gzopen(const char *filepath, const char *mode)
|
||||
/* XXX: Creates file before transcribing the path. */
|
||||
if (mode[0] == 'w') {
|
||||
FILE *file = ufopen(filepath, "a");
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
/* File couldn't be opened, e.g. due to permission error. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
@@ -609,14 +609,14 @@ static bool delete_soft(const wchar_t *path_16, const char **r_error_message)
|
||||
IFileOperation *pfo;
|
||||
IShellItem *psi;
|
||||
|
||||
HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
/* This is also the case when COM was previously initialized and CoInitializeEx returns
|
||||
* S_FALSE, which is not an error. Both HRESULT values S_OK and S_FALSE indicate success. */
|
||||
|
||||
hr = CoCreateInstance(
|
||||
CLSID_FileOperation, NULL, CLSCTX_ALL, IID_IFileOperation, (void **)&pfo);
|
||||
CLSID_FileOperation, nullptr, CLSCTX_ALL, IID_IFileOperation, (void **)&pfo);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
/* Flags for deletion:
|
||||
@@ -626,10 +626,10 @@ static bool delete_soft(const wchar_t *path_16, const char **r_error_message)
|
||||
hr = pfo->SetOperationFlags(FOF_ALLOWUNDO | FOF_SILENT | FOF_WANTNUKEWARNING);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = SHCreateItemFromParsingName(path_16, NULL, IID_IShellItem, (void **)&psi);
|
||||
hr = SHCreateItemFromParsingName(path_16, nullptr, IID_IShellItem, (void **)&psi);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pfo->DeleteItem(psi, NULL);
|
||||
hr = pfo->DeleteItem(psi, nullptr);
|
||||
|
||||
if (SUCCEEDED(hr)) {
|
||||
hr = pfo->PerformOperations();
|
||||
@@ -870,7 +870,7 @@ enum {
|
||||
RecursiveOp_Callback_Error = 2,
|
||||
};
|
||||
|
||||
typedef int (*RecursiveOp_Callback)(const char *from, const char *to);
|
||||
using RecursiveOp_Callback = int (*)(const char *from, const char *to);
|
||||
|
||||
[[maybe_unused]] static bool path_has_trailing_slash(const char *path)
|
||||
{
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
typedef struct {
|
||||
struct RawFileReader {
|
||||
FileReader reader;
|
||||
|
||||
int filedes;
|
||||
} RawFileReader;
|
||||
};
|
||||
|
||||
static int64_t file_read(FileReader *reader, void *buffer, size_t size)
|
||||
{
|
||||
@@ -53,7 +53,7 @@ static void file_close(FileReader *reader)
|
||||
|
||||
FileReader *BLI_filereader_new_file(int filedes)
|
||||
{
|
||||
RawFileReader *rawfile = MEM_callocN(sizeof(RawFileReader), __func__);
|
||||
RawFileReader *rawfile = MEM_cnew<RawFileReader>(__func__);
|
||||
|
||||
rawfile->filedes = filedes;
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <zlib.h>
|
||||
|
||||
#include "BLI_filereader.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
typedef struct {
|
||||
struct GzipReader {
|
||||
FileReader reader;
|
||||
|
||||
FileReader *base;
|
||||
@@ -22,14 +22,14 @@ typedef struct {
|
||||
|
||||
void *in_buf;
|
||||
size_t in_size;
|
||||
} GzipReader;
|
||||
};
|
||||
|
||||
static int64_t gzip_read(FileReader *reader, void *buffer, size_t size)
|
||||
{
|
||||
GzipReader *gzip = (GzipReader *)reader;
|
||||
|
||||
gzip->strm.avail_out = size;
|
||||
gzip->strm.next_out = buffer;
|
||||
gzip->strm.next_out = static_cast<Bytef *>(buffer);
|
||||
|
||||
while (gzip->strm.avail_out > 0) {
|
||||
if (gzip->strm.avail_in == 0) {
|
||||
@@ -39,7 +39,7 @@ static int64_t gzip_read(FileReader *reader, void *buffer, size_t size)
|
||||
if (readsize > 0) {
|
||||
/* We got some data, so mark the buffer as refilled. */
|
||||
gzip->strm.avail_in = readsize;
|
||||
gzip->strm.next_in = gzip->in_buf;
|
||||
gzip->strm.next_in = static_cast<Bytef *>(gzip->in_buf);
|
||||
}
|
||||
else {
|
||||
/* The underlying file is EOF, so return as much as we can. */
|
||||
@@ -74,19 +74,19 @@ static void gzip_close(FileReader *reader)
|
||||
|
||||
FileReader *BLI_filereader_new_gzip(FileReader *base)
|
||||
{
|
||||
GzipReader *gzip = MEM_callocN(sizeof(GzipReader), __func__);
|
||||
GzipReader *gzip = MEM_cnew<GzipReader>(__func__);
|
||||
gzip->base = base;
|
||||
|
||||
if (inflateInit2(&gzip->strm, 16 + MAX_WBITS) != Z_OK) {
|
||||
MEM_freeN(gzip);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
gzip->in_size = 256 * 2014;
|
||||
gzip->in_buf = MEM_mallocN(gzip->in_size, "gzip in buf");
|
||||
|
||||
gzip->reader.read = gzip_read;
|
||||
gzip->reader.seek = NULL;
|
||||
gzip->reader.seek = nullptr;
|
||||
gzip->reader.close = gzip_close;
|
||||
|
||||
return (FileReader *)gzip;
|
||||
@@ -6,29 +6,30 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_fileops.h"
|
||||
#include "BLI_fileops.hh"
|
||||
#include "BLI_filereader.h"
|
||||
#include "BLI_mmap.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
/* This file implements both memory-backed and memory-mapped-file-backed reading. */
|
||||
typedef struct {
|
||||
struct MemoryReader {
|
||||
FileReader reader;
|
||||
|
||||
const char *data;
|
||||
BLI_mmap_file *mmap;
|
||||
size_t length;
|
||||
} MemoryReader;
|
||||
};
|
||||
|
||||
static int64_t memory_read_raw(FileReader *reader, void *buffer, size_t size)
|
||||
{
|
||||
MemoryReader *mem = (MemoryReader *)reader;
|
||||
|
||||
/* Don't read more bytes than there are available in the buffer. */
|
||||
size_t readsize = MIN2(size, (size_t)(mem->length - mem->reader.offset));
|
||||
size_t readsize = std::min(size, (size_t)(mem->length - mem->reader.offset));
|
||||
|
||||
memcpy(buffer, mem->data + mem->reader.offset, readsize);
|
||||
mem->reader.offset += readsize;
|
||||
@@ -69,7 +70,7 @@ static void memory_close_raw(FileReader *reader)
|
||||
|
||||
FileReader *BLI_filereader_new_memory(const void *data, size_t len)
|
||||
{
|
||||
MemoryReader *mem = MEM_callocN(sizeof(MemoryReader), __func__);
|
||||
MemoryReader *mem = MEM_cnew<MemoryReader>(__func__);
|
||||
|
||||
mem->data = (const char *)data;
|
||||
mem->length = len;
|
||||
@@ -92,7 +93,7 @@ static int64_t memory_read_mmap(FileReader *reader, void *buffer, size_t size)
|
||||
MemoryReader *mem = (MemoryReader *)reader;
|
||||
|
||||
/* Don't read more bytes than there are available in the buffer. */
|
||||
size_t readsize = MIN2(size, (size_t)(mem->length - mem->reader.offset));
|
||||
size_t readsize = std::min(size, (size_t)(mem->length - mem->reader.offset));
|
||||
|
||||
if (!BLI_mmap_read(mem->mmap, buffer, mem->reader.offset, readsize)) {
|
||||
return 0;
|
||||
@@ -113,11 +114,11 @@ static void memory_close_mmap(FileReader *reader)
|
||||
FileReader *BLI_filereader_new_mmap(int filedes)
|
||||
{
|
||||
BLI_mmap_file *mmap = BLI_mmap_open(filedes);
|
||||
if (mmap == NULL) {
|
||||
return NULL;
|
||||
if (mmap == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MemoryReader *mem = MEM_callocN(sizeof(MemoryReader), __func__);
|
||||
MemoryReader *mem = MEM_cnew<MemoryReader>(__func__);
|
||||
|
||||
mem->mmap = mmap;
|
||||
mem->length = BLI_mmap_get_length(mmap);
|
||||
@@ -6,11 +6,12 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <zstd.h>
|
||||
|
||||
#include "BLI_fileops.hh"
|
||||
#include "BLI_filereader.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
# include "BLI_endian_switch.h"
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
typedef struct {
|
||||
struct ZstdReader {
|
||||
FileReader reader;
|
||||
|
||||
FileReader *base;
|
||||
@@ -35,7 +36,7 @@ typedef struct {
|
||||
char *cached_content;
|
||||
int cached_frame;
|
||||
} seek;
|
||||
} ZstdReader;
|
||||
};
|
||||
|
||||
static bool zstd_read_u32(FileReader *base, uint32_t *val)
|
||||
{
|
||||
@@ -100,8 +101,10 @@ static bool zstd_read_seek_table(ZstdReader *zstd)
|
||||
}
|
||||
|
||||
zstd->seek.frames_num = frames_num;
|
||||
zstd->seek.compressed_ofs = MEM_malloc_arrayN(frames_num + 1, sizeof(size_t), __func__);
|
||||
zstd->seek.uncompressed_ofs = MEM_malloc_arrayN(frames_num + 1, sizeof(size_t), __func__);
|
||||
zstd->seek.compressed_ofs = static_cast<size_t *>(
|
||||
MEM_malloc_arrayN(frames_num + 1, sizeof(size_t), __func__));
|
||||
zstd->seek.uncompressed_ofs = static_cast<size_t *>(
|
||||
MEM_malloc_arrayN(frames_num + 1, sizeof(size_t), __func__));
|
||||
|
||||
size_t compressed_ofs = 0;
|
||||
size_t uncompressed_ofs = 0;
|
||||
@@ -172,14 +175,14 @@ static const char *zstd_ensure_cache(ZstdReader *zstd, int frame)
|
||||
size_t uncompressed_size = zstd->seek.uncompressed_ofs[frame + 1] -
|
||||
zstd->seek.uncompressed_ofs[frame];
|
||||
|
||||
char *uncompressed_data = MEM_mallocN(uncompressed_size, __func__);
|
||||
char *compressed_data = MEM_mallocN(compressed_size, __func__);
|
||||
char *uncompressed_data = static_cast<char *>(MEM_mallocN(uncompressed_size, __func__));
|
||||
char *compressed_data = static_cast<char *>(MEM_mallocN(compressed_size, __func__));
|
||||
if (zstd->base->seek(zstd->base, zstd->seek.compressed_ofs[frame], SEEK_SET) < 0 ||
|
||||
zstd->base->read(zstd->base, compressed_data, compressed_size) < compressed_size)
|
||||
{
|
||||
MEM_freeN(compressed_data);
|
||||
MEM_freeN(uncompressed_data);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t res = ZSTD_decompressDCtx(
|
||||
@@ -187,7 +190,7 @@ static const char *zstd_ensure_cache(ZstdReader *zstd, int frame)
|
||||
MEM_freeN(compressed_data);
|
||||
if (ZSTD_isError(res) || res < uncompressed_size) {
|
||||
MEM_freeN(uncompressed_data);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
zstd->seek.cached_frame = frame;
|
||||
@@ -208,12 +211,12 @@ static int64_t zstd_read_seekable(FileReader *reader, void *buffer, size_t size)
|
||||
}
|
||||
|
||||
const char *framedata = zstd_ensure_cache(zstd, frame);
|
||||
if (framedata == NULL) {
|
||||
if (framedata == nullptr) {
|
||||
/* Error while reading the frame, so return as much as we can. */
|
||||
break;
|
||||
}
|
||||
|
||||
size_t frame_end_offset = min_zz(zstd->seek.uncompressed_ofs[frame + 1], end_offset);
|
||||
size_t frame_end_offset = std::min(zstd->seek.uncompressed_ofs[frame + 1], end_offset);
|
||||
size_t frame_read_len = frame_end_offset - zstd->reader.offset;
|
||||
|
||||
size_t offset_in_frame = zstd->reader.offset - zstd->seek.uncompressed_ofs[frame];
|
||||
@@ -285,7 +288,7 @@ static void zstd_close(FileReader *reader)
|
||||
if (zstd->reader.seek) {
|
||||
MEM_freeN(zstd->seek.uncompressed_ofs);
|
||||
MEM_freeN(zstd->seek.compressed_ofs);
|
||||
/* When an error has occurred this may be NULL, see: #99744. */
|
||||
/* When an error has occurred this may be nullptr, see: #99744. */
|
||||
if (zstd->seek.cached_content) {
|
||||
MEM_freeN(zstd->seek.cached_content);
|
||||
}
|
||||
@@ -300,7 +303,7 @@ static void zstd_close(FileReader *reader)
|
||||
|
||||
FileReader *BLI_filereader_new_zstd(FileReader *base)
|
||||
{
|
||||
ZstdReader *zstd = MEM_callocN(sizeof(ZstdReader), __func__);
|
||||
ZstdReader *zstd = MEM_cnew<ZstdReader>(__func__);
|
||||
|
||||
zstd->ctx = ZSTD_createDCtx();
|
||||
zstd->base = base;
|
||||
@@ -311,7 +314,7 @@ FileReader *BLI_filereader_new_zstd(FileReader *base)
|
||||
}
|
||||
else {
|
||||
zstd->reader.read = zstd_read;
|
||||
zstd->reader.seek = NULL;
|
||||
zstd->reader.seek = nullptr;
|
||||
|
||||
zstd->in_buf_max_size = ZSTD_DStreamInSize();
|
||||
zstd->in_buf.src = MEM_mallocN(zstd->in_buf_max_size, "zstd in buf");
|
||||
@@ -50,8 +50,8 @@ extern int errno;
|
||||
int
|
||||
fnmatch (const char *pattern, const char *string, int flags)
|
||||
{
|
||||
register const char *p = pattern, *n = string;
|
||||
register char c;
|
||||
const char *p = pattern, *n = string;
|
||||
char c;
|
||||
|
||||
/* Note that this evaluates C many times. */
|
||||
# define FOLD(c) ((flags & FNM_CASEFOLD) && ISUPPER (c) ? tolower (c) : (c))
|
||||
@@ -125,7 +125,6 @@ fnmatch (const char *pattern, const char *string, int flags)
|
||||
case '[':
|
||||
{
|
||||
/* Nonzero if the sense of the character class is inverted. */
|
||||
register int not;
|
||||
|
||||
if (*n == '\0')
|
||||
return FNM_NOMATCH;
|
||||
@@ -134,14 +133,14 @@ fnmatch (const char *pattern, const char *string, int flags)
|
||||
(n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
|
||||
return FNM_NOMATCH;
|
||||
|
||||
not = (*p == '!' || *p == '^');
|
||||
if (not)
|
||||
bool is_not = (*p == '!' || *p == '^');
|
||||
if (is_not)
|
||||
++p;
|
||||
|
||||
c = *p++;
|
||||
for (;;)
|
||||
{
|
||||
register char cstart = c, cend = c;
|
||||
char cstart = c, cend = c;
|
||||
|
||||
if (!(flags & FNM_NOESCAPE) && c == '\\')
|
||||
{
|
||||
@@ -181,7 +180,7 @@ fnmatch (const char *pattern, const char *string, int flags)
|
||||
if (c == ']')
|
||||
break;
|
||||
}
|
||||
if (!not)
|
||||
if (!is_not)
|
||||
return FNM_NOMATCH;
|
||||
break;
|
||||
|
||||
@@ -202,7 +201,7 @@ fnmatch (const char *pattern, const char *string, int flags)
|
||||
++p;
|
||||
}
|
||||
}
|
||||
if (not)
|
||||
if (is_not)
|
||||
return FNM_NOMATCH;
|
||||
}
|
||||
break;
|
||||
@@ -9,7 +9,7 @@
|
||||
* (a queue for fixed length generally small) structures.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -71,7 +71,7 @@ static size_t queue_chunk_elem_max_calc(const size_t elem_size, size_t chunk_siz
|
||||
|
||||
GSQueue *BLI_gsqueue_new(const size_t elem_size)
|
||||
{
|
||||
GSQueue *queue = MEM_callocN(sizeof(*queue), "BLI_gsqueue_new");
|
||||
GSQueue *queue = MEM_cnew<GSQueue>("BLI_gsqueue_new");
|
||||
|
||||
queue->chunk_elem_max = queue_chunk_elem_max_calc(elem_size, CHUNK_SIZE_DEFAULT);
|
||||
queue->elem_size = elem_size;
|
||||
@@ -109,12 +109,13 @@ void BLI_gsqueue_push(GSQueue *queue, const void *item)
|
||||
queue->chunk_free = chunk->next;
|
||||
}
|
||||
else {
|
||||
chunk = MEM_mallocN(sizeof(*chunk) + (queue->elem_size * queue->chunk_elem_max), __func__);
|
||||
chunk = static_cast<QueueChunk *>(
|
||||
MEM_mallocN(sizeof(*chunk) + (queue->elem_size * queue->chunk_elem_max), __func__));
|
||||
}
|
||||
|
||||
chunk->next = NULL;
|
||||
chunk->next = nullptr;
|
||||
|
||||
if (queue->chunk_last == NULL) {
|
||||
if (queue->chunk_last == nullptr) {
|
||||
queue->chunk_first = chunk;
|
||||
}
|
||||
else {
|
||||
@@ -144,8 +145,8 @@ void BLI_gsqueue_pop(GSQueue *queue, void *r_item)
|
||||
|
||||
queue->chunk_first = queue->chunk_first->next;
|
||||
queue->chunk_first_index = 0;
|
||||
if (queue->chunk_first == NULL) {
|
||||
queue->chunk_last = NULL;
|
||||
if (queue->chunk_first == nullptr) {
|
||||
queue->chunk_last = nullptr;
|
||||
queue->chunk_last_index = queue->chunk_elem_max - 1;
|
||||
}
|
||||
|
||||
@@ -161,5 +162,5 @@ size_t BLI_gsqueue_len(const GSQueue *queue)
|
||||
|
||||
bool BLI_gsqueue_is_empty(const GSQueue *queue)
|
||||
{
|
||||
return (queue->chunk_first == NULL);
|
||||
return (queue->chunk_first == nullptr);
|
||||
}
|
||||
@@ -45,13 +45,13 @@
|
||||
#endif
|
||||
|
||||
#if UINT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned int md5_uint32;
|
||||
using md5_uint32 = unsigned int;
|
||||
#else
|
||||
# if USHRT_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned short md5_uint32;
|
||||
using md5_uint32 = unsigned short;
|
||||
# else
|
||||
# if ULONG_MAX == UINT_MAX_32_BITS
|
||||
typedef unsigned long md5_uint32;
|
||||
using md5_uint32 = unsigned long;
|
||||
# else
|
||||
/* The following line is intended to evoke an error. Using #error is not portable enough. */
|
||||
"Cannot determine unsigned 32-bit data type."
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_jitter_2d.h"
|
||||
#include "BLI_rand.h"
|
||||
@@ -139,7 +139,7 @@ void BLI_jitter_init(float (*jitarr)[2], int num)
|
||||
number_fl = (float)num;
|
||||
number_fl_sqrt = sqrtf(number_fl);
|
||||
|
||||
jit2 = MEM_mallocN(12 + (uint)num * sizeof(float[2]), "initjit");
|
||||
jit2 = static_cast<float(*)[2]>(MEM_mallocN(12 + (uint)num * sizeof(float[2]), "initjit"));
|
||||
rad1 = 1.0f / number_fl_sqrt;
|
||||
rad2 = 1.0f / number_fl;
|
||||
rad3 = number_fl_sqrt / number_fl;
|
||||
@@ -11,8 +11,10 @@
|
||||
#include "BLI_kdtree_impl.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_vector.hh"
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
@@ -20,18 +22,18 @@
|
||||
#define _BLI_KDTREE_CONCAT(MACRO_ARG1, MACRO_ARG2) _BLI_KDTREE_CONCAT_AUX(MACRO_ARG1, MACRO_ARG2)
|
||||
#define BLI_kdtree_nd_(id) _BLI_KDTREE_CONCAT(KDTREE_PREFIX_ID, _##id)
|
||||
|
||||
typedef struct KDTreeNode_head {
|
||||
struct KDTreeNode_head {
|
||||
uint left, right;
|
||||
float co[KD_DIMS];
|
||||
int index;
|
||||
} KDTreeNode_head;
|
||||
};
|
||||
|
||||
typedef struct KDTreeNode {
|
||||
struct KDTreeNode {
|
||||
uint left, right;
|
||||
float co[KD_DIMS];
|
||||
int index;
|
||||
uint d; /* range is only (0..KD_DIMS - 1) */
|
||||
} KDTreeNode;
|
||||
};
|
||||
|
||||
struct KDTree {
|
||||
KDTreeNode *nodes;
|
||||
@@ -78,7 +80,7 @@ static float len_squared_vnvn(const float v0[KD_DIMS], const float v1[KD_DIMS])
|
||||
|
||||
static float len_squared_vnvn_cb(const float co_kdtree[KD_DIMS],
|
||||
const float co_search[KD_DIMS],
|
||||
const void *UNUSED(user_data))
|
||||
const void * /*user_data*/)
|
||||
{
|
||||
return len_squared_vnvn(co_kdtree, co_search);
|
||||
}
|
||||
@@ -92,8 +94,9 @@ KDTree *BLI_kdtree_nd_(new)(uint nodes_len_capacity)
|
||||
{
|
||||
KDTree *tree;
|
||||
|
||||
tree = MEM_mallocN(sizeof(KDTree), "KDTree");
|
||||
tree->nodes = MEM_mallocN(sizeof(KDTreeNode) * nodes_len_capacity, "KDTreeNode");
|
||||
tree = MEM_cnew<KDTree>("KDTree");
|
||||
tree->nodes = static_cast<KDTreeNode *>(
|
||||
MEM_mallocN(sizeof(KDTreeNode) * nodes_len_capacity, "KDTreeNode"));
|
||||
tree->nodes_len = 0;
|
||||
tree->root = KD_NODE_ROOT_IS_INIT;
|
||||
tree->max_node_index = -1;
|
||||
@@ -132,7 +135,7 @@ void BLI_kdtree_nd_(insert)(KDTree *tree, int index, const float co[KD_DIMS])
|
||||
copy_vn_vn(node->co, co);
|
||||
node->index = index;
|
||||
node->d = 0;
|
||||
tree->max_node_index = MAX2(tree->max_node_index, index);
|
||||
tree->max_node_index = std::max(tree->max_node_index, index);
|
||||
|
||||
#ifndef NDEBUG
|
||||
tree->is_balanced = false;
|
||||
@@ -162,7 +165,7 @@ static uint kdtree_balance(KDTreeNode *nodes, uint nodes_len, uint axis, const u
|
||||
i = left - 1;
|
||||
j = right;
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
while (nodes[++i].co[axis] < co) { /* pass */
|
||||
}
|
||||
while (nodes[--j].co[axis] > co && j > left) { /* pass */
|
||||
@@ -213,8 +216,8 @@ void BLI_kdtree_nd_(balance)(KDTree *tree)
|
||||
|
||||
static uint *realloc_nodes(uint *stack, uint *stack_len_capacity, const bool is_alloc)
|
||||
{
|
||||
uint *stack_new = MEM_mallocN((*stack_len_capacity + KD_NEAR_ALLOC_INC) * sizeof(uint),
|
||||
"KDTree.treestack");
|
||||
uint *stack_new = static_cast<uint *>(
|
||||
MEM_mallocN((*stack_len_capacity + KD_NEAR_ALLOC_INC) * sizeof(uint), "KDTree.treestack"));
|
||||
memcpy(stack_new, stack, *stack_len_capacity * sizeof(uint));
|
||||
// memset(stack_new + *stack_len_capacity, 0, sizeof(uint) * KD_NEAR_ALLOC_INC);
|
||||
if (is_alloc) {
|
||||
@@ -341,7 +344,7 @@ int BLI_kdtree_nd_(find_nearest_cb)(
|
||||
KDTreeNearest *r_nearest)
|
||||
{
|
||||
const KDTreeNode *nodes = tree->nodes;
|
||||
const KDTreeNode *min_node = NULL;
|
||||
const KDTreeNode *min_node = nullptr;
|
||||
|
||||
uint *stack, stack_default[KD_STACK_INIT];
|
||||
float min_dist = FLT_MAX, cur_dist;
|
||||
@@ -356,7 +359,7 @@ int BLI_kdtree_nd_(find_nearest_cb)(
|
||||
}
|
||||
|
||||
stack = stack_default;
|
||||
stack_len_capacity = ARRAY_SIZE(stack_default);
|
||||
stack_len_capacity = int(ARRAY_SIZE(stack_default));
|
||||
|
||||
#define NODE_TEST_NEAREST(node) \
|
||||
{ \
|
||||
@@ -492,13 +495,13 @@ int BLI_kdtree_nd_(find_nearest_n_with_len_squared_cb)(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len_sq_fn == NULL) {
|
||||
if (len_sq_fn == nullptr) {
|
||||
len_sq_fn = len_squared_vnvn_cb;
|
||||
BLI_assert(user_data == NULL);
|
||||
BLI_assert(user_data == nullptr);
|
||||
}
|
||||
|
||||
stack = stack_default;
|
||||
stack_len_capacity = ARRAY_SIZE(stack_default);
|
||||
stack_len_capacity = int(ARRAY_SIZE(stack_default));
|
||||
|
||||
root = &nodes[tree->root];
|
||||
|
||||
@@ -587,13 +590,13 @@ int BLI_kdtree_nd_(find_nearest_n)(const KDTree *tree,
|
||||
uint nearest_len_capacity)
|
||||
{
|
||||
return BLI_kdtree_nd_(find_nearest_n_with_len_squared_cb)(
|
||||
tree, co, r_nearest, nearest_len_capacity, NULL, NULL);
|
||||
tree, co, r_nearest, nearest_len_capacity, nullptr, nullptr);
|
||||
}
|
||||
|
||||
static int nearest_cmp_dist(const void *a, const void *b)
|
||||
{
|
||||
const KDTreeNearest *kda = a;
|
||||
const KDTreeNearest *kdb = b;
|
||||
const KDTreeNearest *kda = static_cast<const KDTreeNearest *>(a);
|
||||
const KDTreeNearest *kdb = static_cast<const KDTreeNearest *>(b);
|
||||
|
||||
if (kda->dist < kdb->dist) {
|
||||
return -1;
|
||||
@@ -613,8 +616,8 @@ static void nearest_add_in_range(KDTreeNearest **r_nearest,
|
||||
KDTreeNearest *to;
|
||||
|
||||
if (UNLIKELY(nearest_index >= *nearest_len_capacity)) {
|
||||
*r_nearest = MEM_reallocN_id(
|
||||
*r_nearest, (*nearest_len_capacity += KD_FOUND_ALLOC_INC) * sizeof(KDTreeNode), __func__);
|
||||
*r_nearest = static_cast<KDTreeNearest *>(MEM_reallocN_id(
|
||||
*r_nearest, (*nearest_len_capacity += KD_FOUND_ALLOC_INC) * sizeof(KDTreeNode), __func__));
|
||||
}
|
||||
|
||||
to = (*r_nearest) + nearest_index;
|
||||
@@ -641,7 +644,7 @@ int BLI_kdtree_nd_(range_search_with_len_squared_cb)(
|
||||
{
|
||||
const KDTreeNode *nodes = tree->nodes;
|
||||
uint *stack, stack_default[KD_STACK_INIT];
|
||||
KDTreeNearest *nearest = NULL;
|
||||
KDTreeNearest *nearest = nullptr;
|
||||
const float range_sq = range * range;
|
||||
float dist_sq;
|
||||
uint stack_len_capacity, cur = 0;
|
||||
@@ -655,13 +658,13 @@ int BLI_kdtree_nd_(range_search_with_len_squared_cb)(
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (len_sq_fn == NULL) {
|
||||
if (len_sq_fn == nullptr) {
|
||||
len_sq_fn = len_squared_vnvn_cb;
|
||||
BLI_assert(user_data == NULL);
|
||||
BLI_assert(user_data == nullptr);
|
||||
}
|
||||
|
||||
stack = stack_default;
|
||||
stack_len_capacity = ARRAY_SIZE(stack_default);
|
||||
stack_len_capacity = int(ARRAY_SIZE(stack_default));
|
||||
|
||||
stack[cur++] = tree->root;
|
||||
|
||||
@@ -716,7 +719,8 @@ int BLI_kdtree_nd_(range_search)(const KDTree *tree,
|
||||
KDTreeNearest **r_nearest,
|
||||
float range)
|
||||
{
|
||||
return BLI_kdtree_nd_(range_search_with_len_squared_cb)(tree, co, r_nearest, range, NULL, NULL);
|
||||
return BLI_kdtree_nd_(range_search_with_len_squared_cb)(
|
||||
tree, co, r_nearest, range, nullptr, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -750,7 +754,7 @@ void BLI_kdtree_nd_(range_search_cb)(
|
||||
}
|
||||
|
||||
stack = stack_default;
|
||||
stack_len_capacity = ARRAY_SIZE(stack_default);
|
||||
stack_len_capacity = int(ARRAY_SIZE(stack_default));
|
||||
|
||||
stack[cur++] = tree->root;
|
||||
|
||||
@@ -798,12 +802,10 @@ finally:
|
||||
* Use when we want to loop over nodes ordered by index.
|
||||
* Requires indices to be aligned with nodes.
|
||||
*/
|
||||
static int *kdtree_order(const KDTree *tree)
|
||||
static blender::Vector<int> kdtree_order(const KDTree *tree)
|
||||
{
|
||||
const KDTreeNode *nodes = tree->nodes;
|
||||
const size_t bytes_num = sizeof(int) * (size_t)(tree->max_node_index + 1);
|
||||
int *order = MEM_mallocN(bytes_num, __func__);
|
||||
memset(order, -1, bytes_num);
|
||||
blender::Vector<int> order(tree->max_node_index + 1, -1);
|
||||
for (uint i = 0; i < tree->nodes_len; i++) {
|
||||
order[nodes[i].index] = (int)i;
|
||||
}
|
||||
@@ -827,7 +829,7 @@ struct DeDuplicateParams {
|
||||
int search;
|
||||
};
|
||||
|
||||
static void deduplicate_recursive(const struct DeDuplicateParams *p, uint i)
|
||||
static void deduplicate_recursive(const DeDuplicateParams *p, uint i)
|
||||
{
|
||||
const KDTreeNode *node = &p->nodes[i];
|
||||
if (p->search_co[node->d] + p->range <= node->co[node->d]) {
|
||||
@@ -880,16 +882,16 @@ int BLI_kdtree_nd_(calc_duplicates_fast)(const KDTree *tree,
|
||||
int *duplicates)
|
||||
{
|
||||
int found = 0;
|
||||
struct DeDuplicateParams p = {
|
||||
.nodes = tree->nodes,
|
||||
.range = range,
|
||||
.range_sq = square_f(range),
|
||||
.duplicates = duplicates,
|
||||
.duplicates_found = &found,
|
||||
};
|
||||
|
||||
DeDuplicateParams p = {};
|
||||
p.nodes = tree->nodes;
|
||||
p.range = range;
|
||||
p.range_sq = square_f(range);
|
||||
p.duplicates = duplicates;
|
||||
p.duplicates_found = &found;
|
||||
|
||||
if (use_index_order) {
|
||||
int *order = kdtree_order(tree);
|
||||
blender::Vector<int> order = kdtree_order(tree);
|
||||
for (int i = 0; i < tree->max_node_index + 1; i++) {
|
||||
const int node_index = order[i];
|
||||
if (node_index == -1) {
|
||||
@@ -907,7 +909,6 @@ int BLI_kdtree_nd_(calc_duplicates_fast)(const KDTree *tree,
|
||||
}
|
||||
}
|
||||
}
|
||||
MEM_freeN(order);
|
||||
}
|
||||
else {
|
||||
for (uint i = 0; i < tree->nodes_len; i++) {
|
||||
@@ -944,8 +945,8 @@ static int kdtree_cmp_bool(const bool a, const bool b)
|
||||
|
||||
static int kdtree_node_cmp_deduplicate(const void *n0_p, const void *n1_p)
|
||||
{
|
||||
const KDTreeNode *n0 = n0_p;
|
||||
const KDTreeNode *n1 = n1_p;
|
||||
const KDTreeNode *n0 = static_cast<const KDTreeNode *>(n0_p);
|
||||
const KDTreeNode *n1 = static_cast<const KDTreeNode *>(n1_p);
|
||||
for (uint j = 0; j < KD_DIMS; j++) {
|
||||
if (n0->co[j] < n1->co[j]) {
|
||||
return -1;
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Handle External Defines */
|
||||
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
/* check we're not building directly */
|
||||
#if !defined(SORT_IMPL_LINKTYPE) || !defined(SORT_IMPL_FUNC)
|
||||
# error "This file can't be compiled directly, include in another source file"
|
||||
@@ -129,11 +132,11 @@ struct SortInfo {
|
||||
list_node *ranks[MAX_RANKS];
|
||||
};
|
||||
|
||||
BLI_INLINE void init_sort_info(struct SortInfo *si,
|
||||
CompareFn func
|
||||
inline void init_sort_info(struct SortInfo *si,
|
||||
CompareFn func
|
||||
#ifdef SORT_IMPL_USE_THUNK
|
||||
,
|
||||
void *thunk
|
||||
,
|
||||
void *thunk
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -147,12 +150,12 @@ BLI_INLINE void init_sort_info(struct SortInfo *si,
|
||||
#endif
|
||||
}
|
||||
|
||||
BLI_INLINE list_node *merge_lists(list_node *first,
|
||||
list_node *second,
|
||||
CompareFn func
|
||||
inline list_node *merge_lists(list_node *first,
|
||||
list_node *second,
|
||||
CompareFn func
|
||||
#ifdef SORT_IMPL_USE_THUNK
|
||||
,
|
||||
void *thunk
|
||||
,
|
||||
void *thunk
|
||||
#endif
|
||||
)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_listbase.h"
|
||||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
@@ -11,18 +11,14 @@
|
||||
|
||||
#include <float.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_math_constants.h"
|
||||
#include "BLI_math_inline.h"
|
||||
#include "BLI_sys_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* copied from BLI_utildefines.h */
|
||||
#ifdef __GNUC__
|
||||
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
@@ -575,8 +571,6 @@ MINLINE unsigned char unit_float_to_uchar_clamp(float val)
|
||||
return (unsigned char)((
|
||||
(val <= 0.0f) ? 0 : ((val > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * val) + 0.5f))));
|
||||
}
|
||||
#define unit_float_to_uchar_clamp(val) \
|
||||
((CHECK_TYPE_INLINE_NONCONST((val), float)), unit_float_to_uchar_clamp(val))
|
||||
|
||||
MINLINE unsigned short unit_float_to_ushort_clamp(float val)
|
||||
{
|
||||
@@ -584,15 +578,11 @@ MINLINE unsigned short unit_float_to_ushort_clamp(float val)
|
||||
(val <= 0.0f) ? 0 :
|
||||
(val * 65535.0f + 0.5f));
|
||||
}
|
||||
#define unit_float_to_ushort_clamp(val) \
|
||||
((CHECK_TYPE_INLINE_NONCONST(val, float)), unit_float_to_ushort_clamp(val))
|
||||
|
||||
MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
|
||||
{
|
||||
return (unsigned char)(((val) >= 65535 - 128) ? 255 : ((val) + 128) >> 8);
|
||||
}
|
||||
#define unit_ushort_to_uchar(val) \
|
||||
((CHECK_TYPE_INLINE_NONCONST(val, unsigned short)), unit_ushort_to_uchar(val))
|
||||
|
||||
#define unit_float_to_uchar_clamp_v3(v1, v2) \
|
||||
{ \
|
||||
@@ -610,8 +600,4 @@ MINLINE unsigned char unit_ushort_to_uchar(unsigned short val)
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MATH_BASE_INLINE_C__ */
|
||||
@@ -8,10 +8,6 @@
|
||||
#include "BLI_math_base_safe.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
MINLINE float safe_divide(float a, float b)
|
||||
{
|
||||
return (b != 0.0f) ? a / b : 0.0f;
|
||||
@@ -65,8 +61,4 @@ MINLINE float safe_powf(float base, float exponent)
|
||||
return powf(base, exponent);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MATH_BASE_SAFE_INLINE_C__ */
|
||||
@@ -13,6 +13,7 @@
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
#include "BLI_assert.h"
|
||||
#include "BLI_math_bits.h"
|
||||
|
||||
MINLINE unsigned int bitscan_forward_uint(unsigned int a)
|
||||
@@ -18,10 +18,6 @@
|
||||
#ifndef __MATH_COLOR_BLEND_INLINE_C__
|
||||
# define __MATH_COLOR_BLEND_INLINE_C__
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* don't add any saturation to a completely black and white image */
|
||||
# define EPS_SATURATION 0.0005f
|
||||
# define EPS_ALPHA 0.0005f
|
||||
@@ -1135,8 +1131,4 @@ MINLINE void blend_color_interpolate_float(float dst[4],
|
||||
# undef EPS_SATURATION
|
||||
# undef EPS_ALPHA
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* __MATH_COLOR_BLEND_INLINE_C__ */
|
||||
@@ -8,13 +8,8 @@
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_color.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <cmath>
|
||||
|
||||
#ifndef __MATH_COLOR_INLINE_C__
|
||||
# define __MATH_COLOR_INLINE_C__
|
||||
@@ -332,7 +327,3 @@ MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float c
|
||||
}
|
||||
|
||||
#endif /* !__MATH_COLOR_INLINE_C__ */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <cstring>
|
||||
|
||||
/* A few small defines. Keep'em local! */
|
||||
#define SMALL_NUMBER 1.e-8f
|
||||
@@ -70,16 +70,14 @@ MINLINE float axis_dominant_v3_max(int *r_axis_a, int *r_axis_b, const float axi
|
||||
*r_axis_b = 1;
|
||||
return zn;
|
||||
}
|
||||
else if (yn >= xn && yn >= zn) {
|
||||
if (yn >= xn && yn >= zn) {
|
||||
*r_axis_a = 0;
|
||||
*r_axis_b = 2;
|
||||
return yn;
|
||||
}
|
||||
else {
|
||||
*r_axis_a = 1;
|
||||
*r_axis_b = 2;
|
||||
return xn;
|
||||
}
|
||||
*r_axis_a = 1;
|
||||
*r_axis_b = 2;
|
||||
return xn;
|
||||
}
|
||||
|
||||
MINLINE int axis_dominant_v3_single(const float vec[3])
|
||||
@@ -6,9 +6,8 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
#include "BLI_compiler_compat.h"
|
||||
#include "BLI_sys_types.h"
|
||||
@@ -118,7 +117,7 @@ static const float hashpntf[768] = {
|
||||
0.713870, 0.555261, 0.951333,
|
||||
};
|
||||
|
||||
extern "C" const uchar BLI_noise_hash_uchar_512[512] = {
|
||||
const uchar BLI_noise_hash_uchar_512[512] = {
|
||||
0xA2, 0xA0, 0x19, 0x3B, 0xF8, 0xEB, 0xAA, 0xEE, 0xF3, 0x1C, 0x67, 0x28, 0x1D, 0xED, 0x0, 0xDE,
|
||||
0x95, 0x2E, 0xDC, 0x3F, 0x3A, 0x82, 0x35, 0x4D, 0x6C, 0xBA, 0x36, 0xD0, 0xF6, 0xC, 0x79, 0x32,
|
||||
0xD1, 0x59, 0xF4, 0x8, 0x8B, 0x63, 0x89, 0x2F, 0xB8, 0xB4, 0x97, 0x83, 0xF2, 0x8F, 0x18, 0xC7,
|
||||
|
||||
@@ -271,7 +271,7 @@ static int path_normalize_impl(char *path, bool check_blend_relative_prefix)
|
||||
char *start = start_base;
|
||||
char *start_temp;
|
||||
while ((start_temp = strstr(start, SEP_STR ".." SEP_STR)) ||
|
||||
/* Check if the string ends with `/..` & assign when found, else NULL. */
|
||||
/* Check if the string ends with `/..` & assign when found, else nullptr. */
|
||||
(start_temp = ((start <= &path[path_len - 3]) &&
|
||||
STREQ(&path[path_len - 3], SEP_STR "..")) ?
|
||||
&path[path_len - 3] :
|
||||
@@ -445,9 +445,9 @@ bool BLI_path_make_safe_filename_ex(char *filename, bool allow_tokens)
|
||||
#ifdef WIN32
|
||||
{
|
||||
const char *invalid_names[] = {
|
||||
"con", "prn", "aux", "null", "com1", "com2", "com3", "com4",
|
||||
"com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3",
|
||||
"lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", NULL,
|
||||
"con", "prn", "aux", "null", "com1", "com2", "com3", "com4",
|
||||
"com5", "com6", "com7", "com8", "com9", "lpt1", "lpt2", "lpt3",
|
||||
"lpt4", "lpt5", "lpt6", "lpt7", "lpt8", "lpt9", nullptr,
|
||||
};
|
||||
const size_t len = strlen(filename);
|
||||
char *filename_lower = BLI_strdupn(filename, len);
|
||||
@@ -1368,7 +1368,7 @@ void BLI_setenv_if_new(const char *env, const char *val)
|
||||
const char *BLI_getenv(const char *env)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
const char *result = NULL;
|
||||
const char *result = nullptr;
|
||||
/* 32767 is the maximum size of the environment variable on windows,
|
||||
* reserve one more character for the zero terminator. */
|
||||
static wchar_t buffer[32768];
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
* which uses ear clipping, but has no hole support.
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -35,17 +35,17 @@
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
/* local types */
|
||||
typedef struct PolyFill {
|
||||
struct PolyFill {
|
||||
uint edges, verts;
|
||||
float min_xy[2], max_xy[2];
|
||||
ushort nr;
|
||||
uchar f;
|
||||
} PolyFill;
|
||||
};
|
||||
|
||||
typedef struct ScanFillVertLink {
|
||||
struct ScanFillVertLink {
|
||||
ScanFillVert *vert;
|
||||
ScanFillEdge *edge_first, *edge_last;
|
||||
} ScanFillVertLink;
|
||||
};
|
||||
|
||||
/* Local functions. */
|
||||
|
||||
@@ -72,7 +72,8 @@ typedef struct ScanFillVertLink {
|
||||
|
||||
static int vergscdata(const void *a1, const void *a2)
|
||||
{
|
||||
const ScanFillVertLink *x1 = a1, *x2 = a2;
|
||||
const ScanFillVertLink *x1 = static_cast<const ScanFillVertLink *>(a1);
|
||||
const ScanFillVertLink *x2 = static_cast<const ScanFillVertLink *>(a2);
|
||||
|
||||
if (x1->vert->xy[1] < x2->vert->xy[1]) {
|
||||
return 1;
|
||||
@@ -96,11 +97,11 @@ ScanFillVert *BLI_scanfill_vert_add(ScanFillContext *sf_ctx, const float vec[3])
|
||||
{
|
||||
ScanFillVert *sf_v;
|
||||
|
||||
sf_v = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillVert));
|
||||
sf_v = BLI_memarena_alloc<ScanFillVert>(sf_ctx->arena);
|
||||
|
||||
BLI_addtail(&sf_ctx->fillvertbase, sf_v);
|
||||
|
||||
sf_v->tmp.p = NULL;
|
||||
sf_v->tmp.p = nullptr;
|
||||
copy_v3_v3(sf_v->co, vec);
|
||||
|
||||
/* just zero out the rest */
|
||||
@@ -118,7 +119,7 @@ ScanFillEdge *BLI_scanfill_edge_add(ScanFillContext *sf_ctx, ScanFillVert *v1, S
|
||||
{
|
||||
ScanFillEdge *sf_ed;
|
||||
|
||||
sf_ed = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillEdge));
|
||||
sf_ed = BLI_memarena_alloc<ScanFillEdge>(sf_ctx->arena);
|
||||
BLI_addtail(&sf_ctx->filledgebase, sf_ed);
|
||||
|
||||
sf_ed->v1 = v1;
|
||||
@@ -141,7 +142,7 @@ static void addfillface(ScanFillContext *sf_ctx,
|
||||
/* does not make edges */
|
||||
ScanFillFace *sf_tri;
|
||||
|
||||
sf_tri = BLI_memarena_alloc(sf_ctx->arena, sizeof(ScanFillFace));
|
||||
sf_tri = BLI_memarena_alloc<ScanFillFace>(sf_ctx->arena);
|
||||
BLI_addtail(&sf_ctx->fillfacebase, sf_tri);
|
||||
|
||||
sf_tri->v1 = v1;
|
||||
@@ -199,17 +200,14 @@ static void fill_target_map_recursive(const PolyFill *__restrict pf_list,
|
||||
/* add pf2 to pf1 */
|
||||
static void mergepolysSimp(ScanFillContext *sf_ctx, PolyFill *pf1, PolyFill *pf2)
|
||||
{
|
||||
ScanFillVert *eve;
|
||||
ScanFillEdge *eed;
|
||||
|
||||
/* replace old poly numbers */
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (eve->poly_nr == pf2->nr) {
|
||||
eve->poly_nr = pf1->nr;
|
||||
}
|
||||
}
|
||||
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
if (eed->poly_nr == pf2->nr) {
|
||||
eed->poly_nr = pf1->nr;
|
||||
}
|
||||
@@ -219,19 +217,11 @@ static void mergepolysSimp(ScanFillContext *sf_ctx, PolyFill *pf1, PolyFill *pf2
|
||||
pf1->verts += pf2->verts;
|
||||
pf1->edges += pf2->edges;
|
||||
|
||||
if (pf1->max_xy[0] < pf2->max_xy[0]) {
|
||||
pf1->max_xy[0] = pf2->max_xy[0];
|
||||
}
|
||||
if (pf1->max_xy[1] < pf2->max_xy[1]) {
|
||||
pf1->max_xy[1] = pf2->max_xy[1];
|
||||
}
|
||||
pf1->max_xy[0] = std::max(pf1->max_xy[0], pf2->max_xy[0]);
|
||||
pf1->max_xy[1] = std::max(pf1->max_xy[1], pf2->max_xy[1]);
|
||||
|
||||
if (pf1->min_xy[0] > pf2->min_xy[0]) {
|
||||
pf1->min_xy[0] = pf2->min_xy[0];
|
||||
}
|
||||
if (pf1->min_xy[1] > pf2->min_xy[1]) {
|
||||
pf1->min_xy[1] = pf2->min_xy[1];
|
||||
}
|
||||
pf1->min_xy[0] = std::min(pf1->min_xy[0], pf2->min_xy[0]);
|
||||
pf1->min_xy[1] = std::min(pf1->min_xy[1], pf2->min_xy[1]);
|
||||
|
||||
pf1->f = (pf1->f | pf2->f);
|
||||
|
||||
@@ -266,10 +256,10 @@ static bool addedgetoscanvert(ScanFillVertLink *sc, ScanFillEdge *eed)
|
||||
ScanFillEdge *ed;
|
||||
float fac, fac1, x, y;
|
||||
|
||||
if (sc->edge_first == NULL) {
|
||||
if (sc->edge_first == nullptr) {
|
||||
sc->edge_first = sc->edge_last = eed;
|
||||
eed->prev = eed->next = NULL;
|
||||
return 1;
|
||||
eed->prev = eed->next = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
x = eed->v1->xy[0];
|
||||
@@ -335,14 +325,14 @@ static ScanFillVertLink *addedgetoscanlist(ScanFillVertLink *scdata, ScanFillEdg
|
||||
scsearch.vert = eed->v1;
|
||||
sc = (ScanFillVertLink *)bsearch(&scsearch, scdata, len, sizeof(ScanFillVertLink), vergscdata);
|
||||
|
||||
if (UNLIKELY(sc == NULL)) {
|
||||
if (UNLIKELY(sc == nullptr)) {
|
||||
printf("Error in search edge: %p\n", (void *)eed);
|
||||
}
|
||||
else if (addedgetoscanvert(sc, eed) == false) {
|
||||
return sc;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,16 +371,13 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
|
||||
/* only vertices with (->edge_count == 1) are being tested for
|
||||
* being close to an edge, if true insert */
|
||||
|
||||
ScanFillVert *eve;
|
||||
ScanFillEdge *eed, *ed1;
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (eve->edge_count == 1) {
|
||||
/* find the edge which has vertex eve,
|
||||
* NOTE: we _know_ this will crash if 'ed1' becomes NULL
|
||||
* NOTE: we _know_ this will crash if 'ed1' becomes nullptr
|
||||
* but this will never happen. */
|
||||
for (ed1 = sf_ctx->filledgebase.first; !(ed1->v1 == eve || ed1->v2 == eve); ed1 = ed1->next)
|
||||
{
|
||||
ScanFillEdge *ed1 = static_cast<ScanFillEdge *>(sf_ctx->filledgebase.first);
|
||||
for (; !(ed1->v1 == eve || ed1->v2 == eve); ed1 = ed1->next) {
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
@@ -399,7 +386,7 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
|
||||
ed1->v2 = eve;
|
||||
}
|
||||
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
if (eve != eed->v1 && eve != eed->v2 && eve->poly_nr == eed->poly_nr) {
|
||||
if (compare_v2v2(eve->xy, eed->v1->xy, SF_EPSILON)) {
|
||||
ed1->v2 = eed->v1;
|
||||
@@ -436,22 +423,17 @@ static void testvertexnearedge(ScanFillContext *sf_ctx)
|
||||
static void splitlist(ScanFillContext *sf_ctx, ListBase *tempve, ListBase *temped, ushort nr)
|
||||
{
|
||||
/* Everything is in temp-list, write only poly nr to fill-list. */
|
||||
ScanFillVert *eve, *eve_next;
|
||||
ScanFillEdge *eed, *eed_next;
|
||||
|
||||
BLI_movelisttolist(tempve, &sf_ctx->fillvertbase);
|
||||
BLI_movelisttolist(temped, &sf_ctx->filledgebase);
|
||||
|
||||
for (eve = tempve->first; eve; eve = eve_next) {
|
||||
eve_next = eve->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillVert *, eve, tempve) {
|
||||
if (eve->poly_nr == nr) {
|
||||
BLI_remlink(tempve, eve);
|
||||
BLI_addtail(&sf_ctx->fillvertbase, eve);
|
||||
}
|
||||
}
|
||||
|
||||
for (eed = temped->first; eed; eed = eed_next) {
|
||||
eed_next = eed->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillEdge *, eed, temped) {
|
||||
if (eed->poly_nr == nr) {
|
||||
BLI_remlink(temped, eed);
|
||||
BLI_addtail(&sf_ctx->filledgebase, eed);
|
||||
@@ -462,9 +444,8 @@ static void splitlist(ScanFillContext *sf_ctx, ListBase *tempve, ListBase *tempe
|
||||
static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
{
|
||||
ScanFillVertLink *scdata;
|
||||
ScanFillVertLink *sc = NULL, *sc1;
|
||||
ScanFillVert *eve, *v1, *v2, *v3;
|
||||
ScanFillEdge *eed, *eed_next, *ed1, *ed2, *ed3;
|
||||
ScanFillVertLink *sc = nullptr, *sc1;
|
||||
ScanFillVert *v1, *v2, *v3;
|
||||
uint a, b, verts, maxface, totface;
|
||||
const ushort nr = pf->nr;
|
||||
bool twoconnected = false;
|
||||
@@ -472,18 +453,18 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
/* PRINTS */
|
||||
#if 0
|
||||
verts = pf->verts;
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
printf("vert: %x co: %f %f\n", eve, eve->xy[0], eve->xy[1]);
|
||||
}
|
||||
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
printf("edge: %x verts: %x %x\n", eed, eed->v1, eed->v2);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* STEP 0: remove zero sized edges */
|
||||
if (flag & BLI_SCANFILL_CALC_REMOVE_DOUBLES) {
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
if (equals_v2v2(eed->v1->xy, eed->v2->xy)) {
|
||||
if (eed->v1->f == SF_VERT_ZERO_LEN && eed->v2->f != SF_VERT_ZERO_LEN) {
|
||||
eed->v2->f = SF_VERT_ZERO_LEN;
|
||||
@@ -507,18 +488,19 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
/* STEP 1: make using FillVert and FillEdge lists a sorted
|
||||
* ScanFillVertLink list
|
||||
*/
|
||||
sc = scdata = MEM_mallocN(sizeof(*scdata) * pf->verts, "Scanfill1");
|
||||
sc = scdata = static_cast<ScanFillVertLink *>(
|
||||
MEM_mallocN(sizeof(*scdata) * pf->verts, "Scanfill1"));
|
||||
verts = 0;
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (eve->poly_nr == nr) {
|
||||
if (eve->f != SF_VERT_ZERO_LEN) {
|
||||
verts++;
|
||||
eve->f = SF_VERT_NEW; /* Flag for connect edges later on. */
|
||||
sc->vert = eve;
|
||||
sc->edge_first = sc->edge_last = NULL;
|
||||
sc->edge_first = sc->edge_last = nullptr;
|
||||
/* NOTE: debug print only will work for curve poly-fill, union is in use for mesh. */
|
||||
#if 0
|
||||
if (even->tmp.v == NULL) {
|
||||
if (even->tmp.v == nullptr) {
|
||||
eve->tmp.u = verts;
|
||||
}
|
||||
#endif
|
||||
@@ -530,8 +512,7 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
qsort(scdata, verts, sizeof(ScanFillVertLink), vergscdata);
|
||||
|
||||
if (flag & BLI_SCANFILL_CALC_REMOVE_DOUBLES) {
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed_next) {
|
||||
eed_next = eed->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
BLI_remlink(&sf_ctx->filledgebase, eed);
|
||||
/* This code is for handling zero-length edges that get
|
||||
* collapsed in step 0. It was removed for some time to
|
||||
@@ -564,8 +545,7 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed_next) {
|
||||
eed_next = eed->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
BLI_remlink(&sf_ctx->filledgebase, eed);
|
||||
if (eed->v1 != eed->v2) {
|
||||
addedgetoscanlist(scdata, eed, verts);
|
||||
@@ -603,6 +583,7 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
for (a = 0; a < verts; a++) {
|
||||
// printf("VERTEX %d index %d\n", a, sc->vert->tmp.u);
|
||||
/* Set connect-flags. */
|
||||
ScanFillEdge *ed1, *ed2, *ed3, *eed_next;
|
||||
for (ed1 = sc->edge_first; ed1; ed1 = eed_next) {
|
||||
eed_next = ed1->next;
|
||||
if (ed1->v1->edge_count == 1 || ed1->v2->edge_count == 1) {
|
||||
@@ -635,8 +616,8 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
a = verts;
|
||||
break;
|
||||
}
|
||||
if (ed2 == NULL) {
|
||||
sc->edge_first = sc->edge_last = NULL;
|
||||
if (ed2 == nullptr) {
|
||||
sc->edge_first = sc->edge_last = nullptr;
|
||||
// printf("just 1 edge to vert\n");
|
||||
BLI_addtail(&sf_ctx->filledgebase, ed1);
|
||||
ed1->v2->f = SF_VERT_NEW;
|
||||
@@ -645,7 +626,7 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
}
|
||||
else {
|
||||
/* test rest of vertices */
|
||||
ScanFillVertLink *best_sc = NULL;
|
||||
ScanFillVertLink *best_sc = nullptr;
|
||||
float angle_best_cos = -1.0f;
|
||||
float miny;
|
||||
bool firsttime = false;
|
||||
@@ -676,7 +657,7 @@ static uint scanfill(ScanFillContext *sf_ctx, PolyFill *pf, const int flag)
|
||||
/* Because multiple points can be inside triangle
|
||||
* (concave holes) we continue searching and pick the
|
||||
* one with sharpest corner. */
|
||||
if (best_sc == NULL) {
|
||||
if (best_sc == nullptr) {
|
||||
/* even without holes we need to keep checking #35861. */
|
||||
best_sc = sc1;
|
||||
}
|
||||
@@ -805,7 +786,7 @@ void BLI_scanfill_begin_arena(ScanFillContext *sf_ctx, MemArena *arena)
|
||||
void BLI_scanfill_end(ScanFillContext *sf_ctx)
|
||||
{
|
||||
BLI_memarena_free(sf_ctx->arena);
|
||||
sf_ctx->arena = NULL;
|
||||
sf_ctx->arena = nullptr;
|
||||
|
||||
BLI_listbase_clear(&sf_ctx->fillvertbase);
|
||||
BLI_listbase_clear(&sf_ctx->filledgebase);
|
||||
@@ -833,8 +814,6 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
* - returns number of triangle faces added.
|
||||
*/
|
||||
ListBase tempve, temped;
|
||||
ScanFillVert *eve;
|
||||
ScanFillEdge *eed, *eed_next;
|
||||
PolyFill *pflist, *pf;
|
||||
float *min_xy_p, *max_xy_p;
|
||||
uint totfaces = 0; /* total faces added */
|
||||
@@ -845,7 +824,7 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
BLI_assert(!nor_proj || len_squared_v3(nor_proj) > FLT_EPSILON);
|
||||
|
||||
#ifndef NDEBUG
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
/* These values used to be set,
|
||||
* however they should always be zeroed so check instead. */
|
||||
BLI_assert(eve->f == 0);
|
||||
@@ -856,19 +835,21 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
|
||||
/* first test vertices if they are in edges */
|
||||
/* including resetting of flags */
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
BLI_assert(sf_ctx->poly_nr != SF_POLY_UNSET || eed->poly_nr == SF_POLY_UNSET);
|
||||
eed->v1->f = SF_VERT_AVAILABLE;
|
||||
eed->v2->f = SF_VERT_AVAILABLE;
|
||||
}
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
bool vert_available = false;
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (eve->f == SF_VERT_AVAILABLE) {
|
||||
vert_available = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (UNLIKELY(eve == NULL)) {
|
||||
if (UNLIKELY(!vert_available)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -888,10 +869,9 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
const float *v_prev;
|
||||
|
||||
zero_v3(n);
|
||||
eve = sf_ctx->fillvertbase.last;
|
||||
v_prev = eve->co;
|
||||
v_prev = static_cast<ScanFillVert *>(sf_ctx->fillvertbase.last)->co;
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (LIKELY(!compare_v3v3(v_prev, eve->co, SF_EPSILON))) {
|
||||
add_newell_cross_v3_v3v3(n, v_prev, eve->co);
|
||||
v_prev = eve->co;
|
||||
@@ -912,7 +892,7 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
}
|
||||
|
||||
if (flag & BLI_SCANFILL_CALC_POLYS && (poly == 0)) {
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
mul_v2_m3v3(eve->xy, mat_2d, eve->co);
|
||||
|
||||
/* get first vertex with no poly number */
|
||||
@@ -927,9 +907,9 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
ok = false;
|
||||
|
||||
toggle++;
|
||||
for (eed = (toggle & 1) ? sf_ctx->filledgebase.first : sf_ctx->filledgebase.last; eed;
|
||||
eed = (toggle & 1) ? eed->next : eed->prev)
|
||||
{
|
||||
ScanFillEdge *eed = static_cast<ScanFillEdge *>(
|
||||
(toggle & 1) ? sf_ctx->filledgebase.first : sf_ctx->filledgebase.last);
|
||||
for (; eed; eed = (toggle & 1) ? eed->next : eed->prev) {
|
||||
if (eed->v1->poly_nr == SF_POLY_UNSET && eed->v2->poly_nr == poly) {
|
||||
eed->v1->poly_nr = poly;
|
||||
eed->poly_nr = poly;
|
||||
@@ -956,19 +936,19 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
}
|
||||
else if (poly) {
|
||||
/* we pre-calculated poly_nr */
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
mul_v2_m3v3(eve->xy, mat_2d, eve->co);
|
||||
}
|
||||
}
|
||||
else {
|
||||
poly = 1;
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
mul_v2_m3v3(eve->xy, mat_2d, eve->co);
|
||||
eve->poly_nr = 0;
|
||||
}
|
||||
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
eed->poly_nr = 0;
|
||||
}
|
||||
}
|
||||
@@ -976,20 +956,14 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
/* STEP 2: remove loose edges and strings of edges */
|
||||
if (flag & BLI_SCANFILL_CALC_LOOSE) {
|
||||
uint toggle = 0;
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
if (eed->v1->edge_count++ > 250) {
|
||||
break;
|
||||
}
|
||||
if (eed->v2->edge_count++ > 250) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (eed) {
|
||||
/* otherwise it's impossible to be sure you can clear vertices */
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
if ((eed->v1->edge_count++ > 250) || (eed->v2->edge_count++ > 250)) {
|
||||
/* otherwise it's impossible to be sure you can clear vertices */
|
||||
#ifndef NDEBUG
|
||||
printf("No vertices with 250 edges allowed!\n");
|
||||
printf("No vertices with 250 edges allowed!\n");
|
||||
#endif
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* does it only for vertices with (->edge_count == 1) */
|
||||
@@ -1000,9 +974,11 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
ok = false;
|
||||
|
||||
toggle++;
|
||||
for (eed = (toggle & 1) ? sf_ctx->filledgebase.first : sf_ctx->filledgebase.last; eed;
|
||||
eed = eed_next)
|
||||
{
|
||||
|
||||
ScanFillEdge *eed = static_cast<ScanFillEdge *>((toggle & 1) ? sf_ctx->filledgebase.first :
|
||||
sf_ctx->filledgebase.last);
|
||||
ScanFillEdge *eed_next;
|
||||
for (; eed; eed = eed_next) {
|
||||
eed_next = (toggle & 1) ? eed->next : eed->prev;
|
||||
if (eed->v1->edge_count == 1) {
|
||||
eed->v2->edge_count--;
|
||||
@@ -1025,13 +1001,13 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
}
|
||||
else {
|
||||
/* skip checks for loose edges */
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
eed->v1->edge_count++;
|
||||
eed->v2->edge_count++;
|
||||
}
|
||||
#ifndef NDEBUG
|
||||
/* ensure we're right! */
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
BLI_assert(eed->v1->edge_count != 1);
|
||||
BLI_assert(eed->v2->edge_count != 1);
|
||||
}
|
||||
@@ -1049,7 +1025,7 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
*/
|
||||
|
||||
/* STEP 3: MAKE POLYFILL STRUCT */
|
||||
pflist = MEM_mallocN(sizeof(*pflist) * (size_t)poly, "edgefill");
|
||||
pflist = static_cast<PolyFill *>(MEM_mallocN(sizeof(*pflist) * (size_t)poly, "edgefill"));
|
||||
pf = pflist;
|
||||
for (a = 0; a < poly; a++) {
|
||||
pf->edges = pf->verts = 0;
|
||||
@@ -1059,11 +1035,11 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
pf->nr = a;
|
||||
pf++;
|
||||
}
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
pflist[eed->poly_nr].edges++;
|
||||
}
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
pflist[eve->poly_nr].verts++;
|
||||
min_xy_p = pflist[eve->poly_nr].min_xy;
|
||||
max_xy_p = pflist[eve->poly_nr].max_xy;
|
||||
@@ -1091,7 +1067,7 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
}
|
||||
#endif
|
||||
|
||||
uint *target_map = MEM_mallocN(sizeof(*target_map) * (size_t)poly, "polycache");
|
||||
uint *target_map = MEM_cnew_array<uint>(poly, "polycache");
|
||||
range_vn_u(target_map, poly, 0);
|
||||
|
||||
for (a = 0; a < poly; a++) {
|
||||
@@ -1151,5 +1127,5 @@ uint BLI_scanfill_calc_ex(ScanFillContext *sf_ctx, const int flag, const float n
|
||||
|
||||
uint BLI_scanfill_calc(ScanFillContext *sf_ctx, const int flag)
|
||||
{
|
||||
return BLI_scanfill_calc_ex(sf_ctx, flag, NULL);
|
||||
return BLI_scanfill_calc_ex(sf_ctx, flag, nullptr);
|
||||
}
|
||||
@@ -6,12 +6,9 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "DNA_listBase.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_ghash.h"
|
||||
@@ -24,18 +21,18 @@
|
||||
|
||||
#include "BLI_strict_flags.h" /* IWYU pragma: keep. Keep last. */
|
||||
|
||||
typedef struct PolyInfo {
|
||||
struct PolyInfo {
|
||||
ScanFillEdge *edge_first, *edge_last;
|
||||
ScanFillVert *vert_outer;
|
||||
} PolyInfo;
|
||||
};
|
||||
|
||||
typedef struct ScanFillIsect {
|
||||
struct ScanFillIsect {
|
||||
struct ScanFillIsect *next, *prev;
|
||||
float co[3];
|
||||
|
||||
/* newly created vertex */
|
||||
ScanFillVert *v;
|
||||
} ScanFillIsect;
|
||||
};
|
||||
|
||||
#define V_ISISECT 1
|
||||
#define E_ISISECT 1
|
||||
@@ -93,15 +90,13 @@ void BLI_scanfill_obj_dump(ScanFillContext *sf_ctx)
|
||||
|
||||
static ListBase *edge_isect_ls_ensure(GHash *isect_hash, ScanFillEdge *eed)
|
||||
{
|
||||
ListBase *e_ls;
|
||||
void **val_p;
|
||||
|
||||
if (!BLI_ghash_ensure_p(isect_hash, eed, &val_p)) {
|
||||
*val_p = MEM_callocN(sizeof(ListBase), __func__);
|
||||
*val_p = MEM_cnew<ListBase>(__func__);
|
||||
}
|
||||
e_ls = *val_p;
|
||||
|
||||
return e_ls;
|
||||
return static_cast<ListBase *>(*val_p);
|
||||
}
|
||||
|
||||
static ListBase *edge_isect_ls_add(GHash *isect_hash, ScanFillEdge *eed, ScanFillIsect *isect)
|
||||
@@ -109,7 +104,7 @@ static ListBase *edge_isect_ls_add(GHash *isect_hash, ScanFillEdge *eed, ScanFil
|
||||
ListBase *e_ls;
|
||||
LinkData *isect_link;
|
||||
e_ls = edge_isect_ls_ensure(isect_hash, eed);
|
||||
isect_link = MEM_callocN(sizeof(*isect_link), __func__);
|
||||
isect_link = MEM_cnew<LinkData>(__func__);
|
||||
isect_link->data = isect;
|
||||
EFLAG_SET(eed, E_ISISECT);
|
||||
BLI_addtail(e_ls, isect_link);
|
||||
@@ -118,10 +113,12 @@ static ListBase *edge_isect_ls_add(GHash *isect_hash, ScanFillEdge *eed, ScanFil
|
||||
|
||||
static int edge_isect_ls_sort_cb(void *thunk, const void *def_a_ptr, const void *def_b_ptr)
|
||||
{
|
||||
const float *co = thunk;
|
||||
const float *co = static_cast<const float *>(thunk);
|
||||
|
||||
const ScanFillIsect *i_a = ((const LinkData *)def_a_ptr)->data;
|
||||
const ScanFillIsect *i_b = ((const LinkData *)def_b_ptr)->data;
|
||||
const ScanFillIsect *i_a = static_cast<const ScanFillIsect *>(
|
||||
((const LinkData *)def_a_ptr)->data);
|
||||
const ScanFillIsect *i_b = static_cast<const ScanFillIsect *>(
|
||||
((const LinkData *)def_b_ptr)->data);
|
||||
const float a = len_squared_v2v2(co, i_a->co);
|
||||
const float b = len_squared_v2v2(co, i_b->co);
|
||||
|
||||
@@ -156,7 +153,7 @@ static ScanFillEdge *edge_step(PolyInfo *poly_info,
|
||||
}
|
||||
|
||||
BLI_assert(0);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
@@ -165,18 +162,18 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
ListBase *filledgebase)
|
||||
{
|
||||
PolyInfo *pi = &poly_info[poly_nr];
|
||||
GHash *isect_hash = NULL;
|
||||
ListBase isect_lb = {NULL};
|
||||
GHash *isect_hash = nullptr;
|
||||
ListBase isect_lb = {nullptr};
|
||||
|
||||
/* warning, O(n2) check here, should use spatial lookup */
|
||||
{
|
||||
ScanFillEdge *eed;
|
||||
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? NULL : eed->next) {
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? nullptr : eed->next) {
|
||||
ScanFillEdge *eed_other;
|
||||
|
||||
for (eed_other = eed->next; eed_other;
|
||||
eed_other = (eed_other == pi->edge_last) ? NULL : eed_other->next)
|
||||
eed_other = (eed_other == pi->edge_last) ? nullptr : eed_other->next)
|
||||
{
|
||||
if (!ELEM(eed->v1, eed_other->v1, eed_other->v2) &&
|
||||
!ELEM(eed->v2, eed_other->v1, eed_other->v2) && (eed != eed_other))
|
||||
@@ -190,11 +187,11 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
{
|
||||
ScanFillIsect *isect;
|
||||
|
||||
if (UNLIKELY(isect_hash == NULL)) {
|
||||
if (UNLIKELY(isect_hash == nullptr)) {
|
||||
isect_hash = BLI_ghash_ptr_new(__func__);
|
||||
}
|
||||
|
||||
isect = MEM_mallocN(sizeof(ScanFillIsect), __func__);
|
||||
isect = static_cast<ScanFillIsect *>(MEM_mallocN(sizeof(ScanFillIsect), __func__));
|
||||
|
||||
BLI_addtail(&isect_lb, isect);
|
||||
|
||||
@@ -214,7 +211,7 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
}
|
||||
}
|
||||
|
||||
if (isect_hash == NULL) {
|
||||
if (isect_hash == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -222,13 +219,11 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
{
|
||||
ScanFillEdge *eed;
|
||||
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? NULL : eed->next) {
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? nullptr : eed->next) {
|
||||
if (eed->user_flag & E_ISISECT) {
|
||||
ListBase *e_ls = BLI_ghash_lookup(isect_hash, eed);
|
||||
ListBase *e_ls = static_cast<ListBase *>(BLI_ghash_lookup(isect_hash, eed));
|
||||
|
||||
LinkData *isect_link;
|
||||
|
||||
if (UNLIKELY(e_ls == NULL)) {
|
||||
if (UNLIKELY(e_ls == nullptr)) {
|
||||
/* only happens in very rare cases (entirely overlapping splines).
|
||||
* in this case we can't do much useful. but at least don't crash */
|
||||
continue;
|
||||
@@ -236,7 +231,7 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
|
||||
/* Maintain correct terminating edge. */
|
||||
if (pi->edge_last == eed) {
|
||||
pi->edge_last = NULL;
|
||||
pi->edge_last = nullptr;
|
||||
}
|
||||
|
||||
if (BLI_listbase_is_single(e_ls) == false) {
|
||||
@@ -258,8 +253,8 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
eed = eed_tmp;
|
||||
}
|
||||
|
||||
for (isect_link = e_ls->first; isect_link; isect_link = isect_link->next) {
|
||||
ScanFillIsect *isect = isect_link->data;
|
||||
LISTBASE_FOREACH (LinkData *, isect_link, e_ls) {
|
||||
ScanFillIsect *isect = static_cast<ScanFillIsect *>(isect_link->data);
|
||||
ScanFillEdge *eed_subd;
|
||||
|
||||
eed_subd = BLI_scanfill_edge_add(sf_ctx, isect->v, eed->v2);
|
||||
@@ -276,7 +271,7 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
BLI_freelistN(e_ls);
|
||||
MEM_freeN(e_ls);
|
||||
|
||||
if (pi->edge_last == NULL) {
|
||||
if (pi->edge_last == nullptr) {
|
||||
pi->edge_last = eed;
|
||||
}
|
||||
}
|
||||
@@ -284,7 +279,7 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
}
|
||||
|
||||
BLI_freelistN(&isect_lb);
|
||||
BLI_ghash_free(isect_hash, NULL, NULL);
|
||||
BLI_ghash_free(isect_hash, nullptr, nullptr);
|
||||
|
||||
{
|
||||
ScanFillEdge *e_init;
|
||||
@@ -316,7 +311,7 @@ static bool scanfill_preprocess_self_isect(ScanFillContext *sf_ctx,
|
||||
e_next = pi->edge_first;
|
||||
|
||||
eed_prev = pi->edge_last;
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? NULL : eed->next) {
|
||||
for (eed = pi->edge_first; eed; eed = (eed == pi->edge_last) ? nullptr : eed->next) {
|
||||
if (eed->v2->co[0] < min_x) {
|
||||
min_x = eed->v2->co[0];
|
||||
e_curr = eed_prev;
|
||||
@@ -366,40 +361,34 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
|
||||
ListBase *remedgebase)
|
||||
{
|
||||
const uint poly_num = (uint)sf_ctx->poly_nr + 1;
|
||||
uint eed_index = 0;
|
||||
bool changed = false;
|
||||
|
||||
PolyInfo *poly_info;
|
||||
|
||||
if (UNLIKELY(sf_ctx->poly_nr == SF_POLY_UNSET)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
poly_info = MEM_callocN(sizeof(*poly_info) * poly_num, __func__);
|
||||
PolyInfo *poly_info = MEM_cnew_array<PolyInfo>(poly_num, __func__);
|
||||
|
||||
/* get the polygon span */
|
||||
if (sf_ctx->poly_nr == 0) {
|
||||
poly_info->edge_first = sf_ctx->filledgebase.first;
|
||||
poly_info->edge_last = sf_ctx->filledgebase.last;
|
||||
poly_info->edge_first = static_cast<ScanFillEdge *>(sf_ctx->filledgebase.first);
|
||||
poly_info->edge_last = static_cast<ScanFillEdge *>(sf_ctx->filledgebase.last);
|
||||
}
|
||||
else {
|
||||
ushort poly_nr;
|
||||
ScanFillEdge *eed;
|
||||
|
||||
poly_nr = 0;
|
||||
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next, eed_index++) {
|
||||
ushort poly_nr = 0;
|
||||
uint eed_index = 0;
|
||||
|
||||
LISTBASE_FOREACH_INDEX (ScanFillEdge *, eed, &sf_ctx->filledgebase, eed_index) {
|
||||
BLI_assert(eed->poly_nr == eed->v1->poly_nr);
|
||||
BLI_assert(eed->poly_nr == eed->v2->poly_nr);
|
||||
|
||||
if ((poly_info[poly_nr].edge_last != NULL) &&
|
||||
if ((poly_info[poly_nr].edge_last != nullptr) &&
|
||||
(poly_info[poly_nr].edge_last->poly_nr != eed->poly_nr))
|
||||
{
|
||||
poly_nr++;
|
||||
}
|
||||
|
||||
if (poly_info[poly_nr].edge_first == NULL) {
|
||||
if (poly_info[poly_nr].edge_first == nullptr) {
|
||||
poly_info[poly_nr].edge_first = eed;
|
||||
poly_info[poly_nr].edge_last = eed;
|
||||
}
|
||||
@@ -427,10 +416,7 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
|
||||
|
||||
/* move free edges into their own list */
|
||||
{
|
||||
ScanFillEdge *eed;
|
||||
ScanFillEdge *eed_next;
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed_next) {
|
||||
eed_next = eed->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
if (eed->user_flag & E_ISDELETE) {
|
||||
BLI_remlink(&sf_ctx->filledgebase, eed);
|
||||
BLI_addtail(remedgebase, eed);
|
||||
@@ -440,22 +426,17 @@ bool BLI_scanfill_calc_self_isect(ScanFillContext *sf_ctx,
|
||||
|
||||
/* move free vertices into their own list */
|
||||
{
|
||||
ScanFillEdge *eed;
|
||||
ScanFillVert *eve;
|
||||
ScanFillVert *eve_next;
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve->next) {
|
||||
LISTBASE_FOREACH (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
eve->user_flag = 0;
|
||||
eve->poly_nr = SF_POLY_UNSET;
|
||||
}
|
||||
for (eed = sf_ctx->filledgebase.first; eed; eed = eed->next) {
|
||||
LISTBASE_FOREACH (ScanFillEdge *, eed, &sf_ctx->filledgebase) {
|
||||
eed->v1->user_flag = 1;
|
||||
eed->v2->user_flag = 1;
|
||||
eed->poly_nr = SF_POLY_UNSET;
|
||||
}
|
||||
|
||||
for (eve = sf_ctx->fillvertbase.first; eve; eve = eve_next) {
|
||||
eve_next = eve->next;
|
||||
LISTBASE_FOREACH_MUTABLE (ScanFillVert *, eve, &sf_ctx->fillvertbase) {
|
||||
if (eve->user_flag != 1) {
|
||||
BLI_remlink(&sf_ctx->fillvertbase, eve);
|
||||
BLI_addtail(remvertbase, eve);
|
||||
@@ -6,9 +6,7 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#include "BLI_sort.h"
|
||||
|
||||
@@ -26,8 +24,8 @@
|
||||
*
|
||||
* \note modified to use GLIBC argument order for callbacks.
|
||||
*/
|
||||
BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk);
|
||||
BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype);
|
||||
inline char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk);
|
||||
inline void swapfunc(char *a, char *b, int n, int swaptype);
|
||||
|
||||
#define min(a, b) (a) < (b) ? (a) : (b)
|
||||
#define swapcode(TYPE, parmi, parmj, n) \
|
||||
@@ -44,7 +42,7 @@ BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype);
|
||||
#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \
|
||||
es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1;
|
||||
|
||||
BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype)
|
||||
inline void swapfunc(char *a, char *b, int n, int swaptype)
|
||||
{
|
||||
if (swaptype <= 1)
|
||||
swapcode(long, a, b, n)
|
||||
@@ -63,7 +61,7 @@ BLI_INLINE void swapfunc(char *a, char *b, int n, int swaptype)
|
||||
#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype)
|
||||
#define CMP(t, x, y) (cmp((x), (y), (t)))
|
||||
|
||||
BLI_INLINE char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk)
|
||||
inline char *med3(char *a, char *b, char *c, BLI_sort_cmp_t cmp, void *thunk)
|
||||
{
|
||||
return CMP(thunk, a, b) < 0 ?
|
||||
(CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a )) :
|
||||
@@ -24,8 +24,8 @@ struct SortAnyByPtr {
|
||||
|
||||
int BLI_sortutil_cmp_float(const void *a_, const void *b_)
|
||||
{
|
||||
const struct SortAnyByFloat *a = a_;
|
||||
const struct SortAnyByFloat *b = b_;
|
||||
const SortAnyByFloat *a = static_cast<const SortAnyByFloat *>(a_);
|
||||
const SortAnyByFloat *b = static_cast<const SortAnyByFloat *>(b_);
|
||||
if (a->sort_value > b->sort_value) {
|
||||
return 1;
|
||||
}
|
||||
@@ -38,8 +38,8 @@ int BLI_sortutil_cmp_float(const void *a_, const void *b_)
|
||||
|
||||
int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
|
||||
{
|
||||
const struct SortAnyByFloat *a = a_;
|
||||
const struct SortAnyByFloat *b = b_;
|
||||
const SortAnyByFloat *a = static_cast<const SortAnyByFloat *>(a_);
|
||||
const SortAnyByFloat *b = static_cast<const SortAnyByFloat *>(b_);
|
||||
if (a->sort_value < b->sort_value) {
|
||||
return 1;
|
||||
}
|
||||
@@ -52,8 +52,8 @@ int BLI_sortutil_cmp_float_reverse(const void *a_, const void *b_)
|
||||
|
||||
int BLI_sortutil_cmp_int(const void *a_, const void *b_)
|
||||
{
|
||||
const struct SortAnyByInt *a = a_;
|
||||
const struct SortAnyByInt *b = b_;
|
||||
const SortAnyByInt *a = static_cast<const SortAnyByInt *>(a_);
|
||||
const SortAnyByInt *b = static_cast<const SortAnyByInt *>(b_);
|
||||
if (a->sort_value > b->sort_value) {
|
||||
return 1;
|
||||
}
|
||||
@@ -66,8 +66,8 @@ int BLI_sortutil_cmp_int(const void *a_, const void *b_)
|
||||
|
||||
int BLI_sortutil_cmp_int_reverse(const void *a_, const void *b_)
|
||||
{
|
||||
const struct SortAnyByInt *a = a_;
|
||||
const struct SortAnyByInt *b = b_;
|
||||
const SortAnyByInt *a = static_cast<const SortAnyByInt *>(a_);
|
||||
const SortAnyByInt *b = static_cast<const SortAnyByInt *>(b_);
|
||||
if (a->sort_value < b->sort_value) {
|
||||
return 1;
|
||||
}
|
||||
@@ -6,8 +6,8 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <stdlib.h> /* abort() */
|
||||
#include <string.h>
|
||||
#include <cstdlib> /* abort() */
|
||||
#include <cstring>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "MEM_guardedalloc.h"
|
||||
@@ -25,15 +25,15 @@
|
||||
#define CHUNK_ELEM_MIN 32
|
||||
|
||||
struct StackChunk {
|
||||
struct StackChunk *next;
|
||||
StackChunk *next;
|
||||
char data[0];
|
||||
};
|
||||
|
||||
struct BLI_Stack {
|
||||
struct StackChunk *chunk_curr; /* currently active chunk */
|
||||
struct StackChunk *chunk_free; /* free chunks */
|
||||
size_t chunk_index; /* index into 'chunk_curr' */
|
||||
size_t chunk_elem_max; /* number of elements per chunk */
|
||||
StackChunk *chunk_curr; /* currently active chunk */
|
||||
StackChunk *chunk_free; /* free chunks */
|
||||
size_t chunk_index; /* index into 'chunk_curr' */
|
||||
size_t chunk_elem_max; /* number of elements per chunk */
|
||||
size_t elem_size;
|
||||
#ifdef USE_TOTELEM
|
||||
size_t elem_num;
|
||||
@@ -60,7 +60,7 @@ static size_t stack_chunk_elem_max_calc(const size_t elem_size, size_t chunk_siz
|
||||
}
|
||||
|
||||
/* account for slop-space */
|
||||
chunk_size -= (sizeof(struct StackChunk) + MEM_SIZE_OVERHEAD);
|
||||
chunk_size -= (sizeof(StackChunk) + MEM_SIZE_OVERHEAD);
|
||||
|
||||
return chunk_size / elem_size;
|
||||
}
|
||||
@@ -69,7 +69,7 @@ BLI_Stack *BLI_stack_new_ex(const size_t elem_size,
|
||||
const char *description,
|
||||
const size_t chunk_size)
|
||||
{
|
||||
BLI_Stack *stack = MEM_callocN(sizeof(*stack), description);
|
||||
BLI_Stack *stack = MEM_cnew<BLI_Stack>(description);
|
||||
|
||||
stack->chunk_elem_max = stack_chunk_elem_max_calc(elem_size, chunk_size);
|
||||
stack->elem_size = elem_size;
|
||||
@@ -84,10 +84,10 @@ BLI_Stack *BLI_stack_new(const size_t elem_size, const char *description)
|
||||
return BLI_stack_new_ex(elem_size, description, CHUNK_SIZE_DEFAULT);
|
||||
}
|
||||
|
||||
static void stack_free_chunks(struct StackChunk *data)
|
||||
static void stack_free_chunks(StackChunk *data)
|
||||
{
|
||||
while (data) {
|
||||
struct StackChunk *data_next = data->next;
|
||||
StackChunk *data_next = data->next;
|
||||
MEM_freeN(data);
|
||||
data = data_next;
|
||||
}
|
||||
@@ -105,13 +105,14 @@ void *BLI_stack_push_r(BLI_Stack *stack)
|
||||
stack->chunk_index++;
|
||||
|
||||
if (UNLIKELY(stack->chunk_index == stack->chunk_elem_max)) {
|
||||
struct StackChunk *chunk;
|
||||
StackChunk *chunk;
|
||||
if (stack->chunk_free) {
|
||||
chunk = stack->chunk_free;
|
||||
stack->chunk_free = chunk->next;
|
||||
}
|
||||
else {
|
||||
chunk = MEM_mallocN(sizeof(*chunk) + (stack->elem_size * stack->chunk_elem_max), __func__);
|
||||
chunk = static_cast<StackChunk *>(
|
||||
MEM_mallocN(sizeof(*chunk) + (stack->elem_size * stack->chunk_elem_max), __func__));
|
||||
}
|
||||
chunk->next = stack->chunk_curr;
|
||||
stack->chunk_curr = chunk;
|
||||
@@ -180,7 +181,7 @@ void BLI_stack_discard(BLI_Stack *stack)
|
||||
stack->elem_num--;
|
||||
#endif
|
||||
if (UNLIKELY(--stack->chunk_index == CHUNK_EMPTY)) {
|
||||
struct StackChunk *chunk_free;
|
||||
StackChunk *chunk_free;
|
||||
|
||||
chunk_free = stack->chunk_curr;
|
||||
stack->chunk_curr = stack->chunk_curr->next;
|
||||
@@ -200,7 +201,7 @@ void BLI_stack_clear(BLI_Stack *stack)
|
||||
}
|
||||
stack->elem_num = 0;
|
||||
#else
|
||||
if (UNLIKELY(stack->chunk_curr == NULL)) {
|
||||
if (UNLIKELY(stack->chunk_curr == nullptr)) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -210,17 +211,17 @@ void BLI_stack_clear(BLI_Stack *stack)
|
||||
if (stack->chunk_free) {
|
||||
if (stack->chunk_curr) {
|
||||
/* move all used chunks into tail of free list */
|
||||
struct StackChunk *chunk_free_last = stack->chunk_free;
|
||||
StackChunk *chunk_free_last = stack->chunk_free;
|
||||
while (chunk_free_last->next) {
|
||||
chunk_free_last = chunk_free_last->next;
|
||||
}
|
||||
chunk_free_last->next = stack->chunk_curr;
|
||||
stack->chunk_curr = NULL;
|
||||
stack->chunk_curr = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
stack->chunk_free = stack->chunk_curr;
|
||||
stack->chunk_curr = NULL;
|
||||
stack->chunk_curr = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,7 +230,7 @@ size_t BLI_stack_count(const BLI_Stack *stack)
|
||||
#ifdef USE_TOTELEM
|
||||
return stack->elem_num;
|
||||
#else
|
||||
struct StackChunk *data = stack->chunk_curr;
|
||||
StackChunk *data = stack->chunk_curr;
|
||||
size_t elem_num = stack->chunk_index + 1;
|
||||
size_t i;
|
||||
if (elem_num != stack->chunk_elem_max) {
|
||||
@@ -249,7 +250,7 @@ size_t BLI_stack_count(const BLI_Stack *stack)
|
||||
bool BLI_stack_is_empty(const BLI_Stack *stack)
|
||||
{
|
||||
#ifdef USE_TOTELEM
|
||||
BLI_assert((stack->chunk_curr == NULL) == (stack->elem_num == 0));
|
||||
BLI_assert((stack->chunk_curr == nullptr) == (stack->elem_num == 0));
|
||||
#endif
|
||||
return (stack->chunk_curr == NULL);
|
||||
return (stack->chunk_curr == nullptr);
|
||||
}
|
||||
@@ -91,7 +91,7 @@ char *BLI_current_working_dir(char *dir, const size_t maxncpy)
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
# else
|
||||
const char *pwd = BLI_getenv("PWD");
|
||||
if (pwd) {
|
||||
@@ -328,14 +328,14 @@ bool BLI_file_alias_target(const char *filepath,
|
||||
return false;
|
||||
}
|
||||
|
||||
HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
|
||||
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||
if (FAILED(hr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IShellLinkW *Shortcut = NULL;
|
||||
IShellLinkW *Shortcut = nullptr;
|
||||
hr = CoCreateInstance(
|
||||
CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&Shortcut);
|
||||
CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (LPVOID *)&Shortcut);
|
||||
|
||||
bool success = false;
|
||||
if (SUCCEEDED(hr)) {
|
||||
@@ -349,7 +349,7 @@ bool BLI_file_alias_target(const char *filepath,
|
||||
hr = Shortcut->Resolve(0, SLR_NO_UI | SLR_UPDATE | SLR_NOSEARCH);
|
||||
if (SUCCEEDED(hr)) {
|
||||
wchar_t target_utf16[FILE_MAXDIR] = {0};
|
||||
hr = Shortcut->GetPath(target_utf16, FILE_MAXDIR, NULL, 0);
|
||||
hr = Shortcut->GetPath(target_utf16, FILE_MAXDIR, nullptr, 0);
|
||||
if (SUCCEEDED(hr)) {
|
||||
success = (conv_utf_16_to_8(target_utf16, r_targetpath, FILE_MAXDIR) == 0);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -30,7 +31,7 @@ char *BLI_strdupn(const char *str, const size_t len)
|
||||
{
|
||||
BLI_assert_msg(BLI_strnlen(str, len) == len, "strlen(str) must be greater or equal to 'len'!");
|
||||
|
||||
char *n = MEM_mallocN(len + 1, "strdup");
|
||||
char *n = static_cast<char *>(MEM_mallocN(len + 1, "strdup"));
|
||||
memcpy(n, str, len);
|
||||
n[len] = '\0';
|
||||
|
||||
@@ -44,17 +45,17 @@ char *BLI_strdup(const char *str)
|
||||
|
||||
char *BLI_strdup_null(const char *str)
|
||||
{
|
||||
return (str != NULL) ? BLI_strdupn(str, strlen(str)) : NULL;
|
||||
return (str != nullptr) ? BLI_strdupn(str, strlen(str)) : nullptr;
|
||||
}
|
||||
|
||||
char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
|
||||
{
|
||||
/* include the NULL terminator of str2 only */
|
||||
/* include the nullptr terminator of str2 only */
|
||||
const size_t str1_len = strlen(str1);
|
||||
const size_t str2_len = strlen(str2) + 1;
|
||||
char *str, *s;
|
||||
|
||||
str = MEM_mallocN(str1_len + str2_len, "strdupcat");
|
||||
str = MEM_cnew_array<char>(str1_len + str2_len, "strdupcat");
|
||||
s = str;
|
||||
|
||||
memcpy(s, str1, str1_len); /* NOLINT: bugprone-not-null-terminated-result */
|
||||
@@ -159,9 +160,9 @@ size_t BLI_vsnprintf(char *__restrict dst,
|
||||
|
||||
size_t n;
|
||||
|
||||
BLI_assert(dst != NULL);
|
||||
BLI_assert(dst != nullptr);
|
||||
BLI_assert(dst_maxncpy > 0);
|
||||
BLI_assert(format != NULL);
|
||||
BLI_assert(format != nullptr);
|
||||
|
||||
n = (size_t)vsnprintf(dst, dst_maxncpy, format, arg);
|
||||
|
||||
@@ -184,9 +185,9 @@ size_t BLI_vsnprintf_rlen(char *__restrict dst,
|
||||
|
||||
size_t n;
|
||||
|
||||
BLI_assert(dst != NULL);
|
||||
BLI_assert(dst != nullptr);
|
||||
BLI_assert(dst_maxncpy > 0);
|
||||
BLI_assert(format != NULL);
|
||||
BLI_assert(format != nullptr);
|
||||
|
||||
n = (size_t)vsnprintf(dst, dst_maxncpy, format, arg);
|
||||
|
||||
@@ -243,7 +244,7 @@ char *BLI_sprintfN_with_buffer(
|
||||
/* Return an empty string as there was an error there is no valid output. */
|
||||
*result_len = 0;
|
||||
if (UNLIKELY(fixed_buf_size == 0)) {
|
||||
return MEM_callocN(sizeof(char), __func__);
|
||||
return MEM_cnew_array<char>(1, __func__);
|
||||
}
|
||||
*fixed_buf = '\0';
|
||||
return fixed_buf;
|
||||
@@ -255,7 +256,7 @@ char *BLI_sprintfN_with_buffer(
|
||||
|
||||
/* `retval` doesn't include null terminator. */
|
||||
const size_t size = (size_t)retval + 1;
|
||||
char *result = MEM_mallocN(sizeof(char) * size, __func__);
|
||||
char *result = static_cast<char *>(MEM_mallocN(sizeof(char) * size, __func__));
|
||||
va_start(args, format);
|
||||
retval = vsnprintf(result, size, format, args);
|
||||
va_end(args);
|
||||
@@ -278,7 +279,7 @@ char *BLI_vsprintfN_with_buffer(char *fixed_buf,
|
||||
/* Return an empty string as there was an error there is no valid output. */
|
||||
*result_len = 0;
|
||||
if (UNLIKELY(fixed_buf_size == 0)) {
|
||||
return MEM_callocN(sizeof(char), __func__);
|
||||
return MEM_cnew_array<char>(1, __func__);
|
||||
}
|
||||
*fixed_buf = '\0';
|
||||
return fixed_buf;
|
||||
@@ -290,7 +291,7 @@ char *BLI_vsprintfN_with_buffer(char *fixed_buf,
|
||||
|
||||
/* `retval` doesn't include null terminator. */
|
||||
const size_t size = (size_t)retval + 1;
|
||||
char *result = MEM_mallocN(sizeof(char) * size, __func__);
|
||||
char *result = static_cast<char *>(MEM_mallocN(sizeof(char) * size, __func__));
|
||||
retval = vsnprintf(result, size, format, args);
|
||||
BLI_assert((size_t)(retval + 1) == size);
|
||||
UNUSED_VARS_NDEBUG(retval);
|
||||
@@ -310,7 +311,7 @@ char *BLI_sprintfN(const char *__restrict format, ...)
|
||||
return result;
|
||||
}
|
||||
size_t size = result_len + 1;
|
||||
result = MEM_mallocN(sizeof(char) * size, __func__);
|
||||
result = static_cast<char *>(MEM_mallocN(sizeof(char) * size, __func__));
|
||||
memcpy(result, fixed_buf, size);
|
||||
return result;
|
||||
}
|
||||
@@ -325,7 +326,7 @@ char *BLI_vsprintfN(const char *__restrict format, va_list args)
|
||||
return result;
|
||||
}
|
||||
size_t size = result_len + 1;
|
||||
result = MEM_mallocN(sizeof(char) * size, __func__);
|
||||
result = MEM_cnew_array<char>(size, __func__);
|
||||
memcpy(result, fixed_buf, size);
|
||||
return result;
|
||||
}
|
||||
@@ -440,7 +441,7 @@ const char *BLI_str_escape_find_quote(const char *str)
|
||||
escape = (escape == false) && (*str == '\\');
|
||||
str++;
|
||||
}
|
||||
return (*str == '"') ? str : NULL;
|
||||
return (*str == '"') ? str : nullptr;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
@@ -455,7 +456,7 @@ bool BLI_str_quoted_substr_range(const char *__restrict str,
|
||||
int *__restrict r_end)
|
||||
{
|
||||
const char *str_start = strstr(str, prefix);
|
||||
if (str_start == NULL) {
|
||||
if (str_start == nullptr) {
|
||||
return false;
|
||||
}
|
||||
const size_t prefix_len = strlen(prefix);
|
||||
@@ -475,7 +476,7 @@ bool BLI_str_quoted_substr_range(const char *__restrict str,
|
||||
}
|
||||
str_start += 1;
|
||||
const char *str_end = BLI_str_escape_find_quote(str_start);
|
||||
if (UNLIKELY(str_end == NULL)) {
|
||||
if (UNLIKELY(str_end == nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -502,7 +503,7 @@ char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict
|
||||
{
|
||||
int start_match_ofs, end_match_ofs;
|
||||
if (!BLI_str_quoted_substr_range(str, prefix, &start_match_ofs, &end_match_ofs)) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
const size_t escaped_len = (size_t)(end_match_ofs - start_match_ofs);
|
||||
char *result = MEM_mallocN(sizeof(char) * (escaped_len + 1), __func__);
|
||||
@@ -556,7 +557,7 @@ char *BLI_strcasestr(const char *s, const char *find)
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
sc = (char)tolower(sc);
|
||||
} while (sc != c);
|
||||
@@ -609,7 +610,7 @@ char *BLI_strncasestr(const char *s, const char *find, size_t len)
|
||||
do {
|
||||
do {
|
||||
if ((sc = *s++) == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
sc = (char)tolower(sc);
|
||||
} while (sc != c);
|
||||
@@ -619,7 +620,7 @@ char *BLI_strncasestr(const char *s, const char *find, size_t len)
|
||||
{
|
||||
do {
|
||||
if ((sc = *s++) == 0) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
sc = (char)tolower(sc);
|
||||
} while (sc != c);
|
||||
@@ -736,7 +737,7 @@ int BLI_strcasecmp_natural(const char *s1, const char *s2)
|
||||
* then increase string deltas as long they are
|
||||
* numeric, else do a tolower and char compare */
|
||||
|
||||
while (1) {
|
||||
while (true) {
|
||||
if (isdigit(s1[d1]) && isdigit(s2[d2])) {
|
||||
int numcompare = left_number_strcmp(s1 + d1, s2 + d2, &tiebreaker);
|
||||
|
||||
@@ -1024,12 +1025,12 @@ int BLI_str_rstrip_digits(char *str)
|
||||
|
||||
size_t BLI_str_partition(const char *str, const char delim[], const char **sep, const char **suf)
|
||||
{
|
||||
return BLI_str_partition_ex(str, NULL, delim, sep, suf, false);
|
||||
return BLI_str_partition_ex(str, nullptr, delim, sep, suf, false);
|
||||
}
|
||||
|
||||
size_t BLI_str_rpartition(const char *str, const char delim[], const char **sep, const char **suf)
|
||||
{
|
||||
return BLI_str_partition_ex(str, NULL, delim, sep, suf, true);
|
||||
return BLI_str_partition_ex(str, nullptr, delim, sep, suf, true);
|
||||
}
|
||||
|
||||
size_t BLI_str_partition_ex(const char *str,
|
||||
@@ -1040,11 +1041,10 @@ size_t BLI_str_partition_ex(const char *str,
|
||||
const bool from_right)
|
||||
{
|
||||
const char *d;
|
||||
char *(*func)(const char *str, int c) = from_right ? strrchr : strchr;
|
||||
|
||||
BLI_assert(end == NULL || end > str);
|
||||
BLI_assert(end == nullptr || end > str);
|
||||
|
||||
*sep = *suf = NULL;
|
||||
*sep = *suf = nullptr;
|
||||
|
||||
for (d = delim; *d != '\0'; d++) {
|
||||
const char *tmp;
|
||||
@@ -1055,18 +1055,18 @@ size_t BLI_str_partition_ex(const char *str,
|
||||
/* pass */
|
||||
}
|
||||
if (tmp < str) {
|
||||
tmp = NULL;
|
||||
tmp = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
tmp = func(str, *d);
|
||||
tmp = (from_right) ? strrchr(str, *d) : strchr(str, *d);
|
||||
if (tmp >= end) {
|
||||
tmp = NULL;
|
||||
tmp = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
tmp = func(str, *d);
|
||||
tmp = (from_right) ? strrchr(str, *d) : strchr(str, *d);
|
||||
}
|
||||
|
||||
if (tmp && (from_right ? (*sep < tmp) : (!*sep || *sep > tmp))) {
|
||||
@@ -1202,7 +1202,7 @@ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE],
|
||||
const int base = base_10 ? 1000 : 1024;
|
||||
const char *units_base_10[] = {"B", "KB", "MB", "GB", "TB", "PB"};
|
||||
const char *units_base_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
|
||||
const int units_num = ARRAY_SIZE(units_base_2);
|
||||
const int units_num = int(ARRAY_SIZE(units_base_2));
|
||||
|
||||
BLI_STATIC_ASSERT(ARRAY_SIZE(units_base_2) == ARRAY_SIZE(units_base_10), "array size mismatch");
|
||||
|
||||
@@ -1210,7 +1210,7 @@ void BLI_str_format_byte_unit(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_SIZE],
|
||||
bytes_converted /= base;
|
||||
order++;
|
||||
}
|
||||
decimals = MAX2(order - 1, 0);
|
||||
decimals = std::max(order - 1, 0);
|
||||
|
||||
/* Format value first, stripping away floating zeroes. */
|
||||
size_t len = BLI_snprintf_rlen(dst, dst_maxncpy, "%.*f", decimals, bytes_converted);
|
||||
@@ -1228,12 +1228,12 @@ void BLI_str_format_byte_unit_compact(char dst[BLI_STR_FORMAT_INT64_BYTE_UNIT_CO
|
||||
|
||||
float number_to_format_converted = (float)bytes;
|
||||
int order = 0;
|
||||
const int base = base_10 ? 1000 : 1024;
|
||||
const float base = base_10 ? 1000.0f : 1024.0f;
|
||||
const char *units[] = {"B", "K", "M", "G", "T", "P"};
|
||||
const int units_num = ARRAY_SIZE(units);
|
||||
const int units_num = int(ARRAY_SIZE(units));
|
||||
|
||||
while ((fabsf(number_to_format_converted) >= base) && ((order + 1) < units_num)) {
|
||||
number_to_format_converted /= (float)base;
|
||||
number_to_format_converted /= base;
|
||||
order++;
|
||||
}
|
||||
|
||||
@@ -1259,9 +1259,9 @@ void BLI_str_format_decimal_unit(char dst[BLI_STR_FORMAT_INT32_DECIMAL_UNIT_SIZE
|
||||
|
||||
float number_to_format_converted = (float)number_to_format;
|
||||
int order = 0;
|
||||
const float base = 1000;
|
||||
const float base = 1000.0f;
|
||||
const char *units[] = {"", "K", "M", "B"};
|
||||
const int units_num = ARRAY_SIZE(units);
|
||||
const int units_num = int(ARRAY_SIZE(units));
|
||||
|
||||
while ((fabsf(number_to_format_converted) >= base) && ((order + 1) < units_num)) {
|
||||
number_to_format_converted /= base;
|
||||
@@ -1286,7 +1286,7 @@ void BLI_str_format_integer_unit(char dst[BLI_STR_FORMAT_INT32_INTEGER_UNIT_SIZE
|
||||
int order = 0;
|
||||
const float base = 1000;
|
||||
const char *units[] = {"", "K", "M", "B"};
|
||||
const int units_num = ARRAY_SIZE(units);
|
||||
const int units_num = int(ARRAY_SIZE(units));
|
||||
|
||||
while ((fabsf(number_to_format_converted) >= base) && ((order + 1) < units_num)) {
|
||||
number_to_format_converted /= base;
|
||||
@@ -6,8 +6,9 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "BLI_string_utf8.h"
|
||||
#include "BLI_utildefines.h"
|
||||
@@ -28,7 +29,7 @@
|
||||
* This is done so expanding the range at a word boundary always chooses the word instead
|
||||
* of the white-space before or after it.
|
||||
*/
|
||||
typedef enum eStrCursorDelimType {
|
||||
enum eStrCursorDelimType {
|
||||
STRCUR_DELIM_NONE,
|
||||
STRCUR_DELIM_ALPHANUMERIC,
|
||||
STRCUR_DELIM_PUNCT,
|
||||
@@ -37,7 +38,7 @@ typedef enum eStrCursorDelimType {
|
||||
STRCUR_DELIM_QUOTE,
|
||||
STRCUR_DELIM_OTHER,
|
||||
STRCUR_DELIM_WHITESPACE,
|
||||
} eStrCursorDelimType;
|
||||
};
|
||||
|
||||
static eStrCursorDelimType cursor_delim_type_unicode(const uint uch)
|
||||
{
|
||||
@@ -151,9 +152,7 @@ bool BLI_str_cursor_step_next_utf8(const char *str, const int str_maxlen, int *p
|
||||
} while ((str_next < str_end) && (str_next[0] != 0) &&
|
||||
(BLI_str_utf8_char_width_or_error(str_next) == 0));
|
||||
*pos += (int)(str_next - str_pos);
|
||||
if (*pos > str_maxlen) {
|
||||
*pos = str_maxlen;
|
||||
}
|
||||
*pos = std::min(*pos, str_maxlen);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ int BLI_str_utf8_invalid_strip(char *str, size_t length)
|
||||
break;
|
||||
}
|
||||
/* strip, keep looking */
|
||||
memmove(str, str + 1, length + 1); /* +1 for NULL char! */
|
||||
memmove(str, str + 1, length + 1); /* +1 for nullptr char! */
|
||||
tot++;
|
||||
}
|
||||
|
||||
@@ -888,7 +888,7 @@ size_t BLI_str_utf8_from_unicode(uint c, char *dst, const size_t dst_maxncpy)
|
||||
UTF8_VARS_FROM_CHAR32(c, first, len);
|
||||
|
||||
if (UNLIKELY(dst_maxncpy < len)) {
|
||||
/* NULL terminate instead of writing a partial byte. */
|
||||
/* nullptr terminate instead of writing a partial byte. */
|
||||
memset(dst, 0x0, dst_maxncpy);
|
||||
return dst_maxncpy;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <climits>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_string.h"
|
||||
@@ -60,7 +60,7 @@ int BLI_cpu_support_sse2(void)
|
||||
|
||||
/* Windows stack-walk lives in system_win32.cc */
|
||||
#if !defined(_MSC_VER)
|
||||
void BLI_system_backtrace_with_os_info(FILE *fp, const void *UNUSED(os_info))
|
||||
void BLI_system_backtrace_with_os_info(FILE *fp, const void * /*os_info*/)
|
||||
{
|
||||
/* ----------------------- */
|
||||
/* If system as execinfo.h */
|
||||
@@ -101,7 +101,7 @@ void BLI_system_backtrace_with_os_info(FILE *fp, const void *UNUSED(os_info))
|
||||
|
||||
void BLI_system_backtrace(FILE *fp)
|
||||
{
|
||||
BLI_system_backtrace_with_os_info(fp, NULL);
|
||||
BLI_system_backtrace_with_os_info(fp, nullptr);
|
||||
}
|
||||
|
||||
/* NOTE: The code for CPU brand string is adopted from Cycles. */
|
||||
@@ -152,14 +152,14 @@ char *BLI_cpu_brand_string(void)
|
||||
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
|
||||
"ProcessorNameString",
|
||||
RRF_RT_REG_SZ,
|
||||
NULL,
|
||||
nullptr,
|
||||
&processorNameString,
|
||||
&processorNameStringLength) == ERROR_SUCCESS)
|
||||
{
|
||||
return BLI_strdup(processorNameString);
|
||||
}
|
||||
#endif
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int BLI_cpu_support_sse42(void)
|
||||
@@ -8,14 +8,13 @@
|
||||
* Parallel tasks over all elements in a container.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_mempool.h"
|
||||
#include "BLI_mempool_private.h"
|
||||
#include "BLI_task.h"
|
||||
#include "BLI_threads.h"
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Macros
|
||||
@@ -24,7 +23,7 @@
|
||||
/* Allows to avoid using malloc for userdata_chunk in tasks, when small enough. */
|
||||
#define MALLOCA(_size) ((_size) <= 8192) ? alloca(_size) : MEM_mallocN((_size), __func__)
|
||||
#define MALLOCA_FREE(_mem, _size) \
|
||||
if (((_mem) != NULL) && ((_size) > 8192)) { \
|
||||
if (((_mem) != nullptr) && ((_size) > 8192)) { \
|
||||
MEM_freeN(_mem); \
|
||||
} \
|
||||
((void)0)
|
||||
@@ -35,19 +34,20 @@
|
||||
/** \name MemPool Iteration
|
||||
* \{ */
|
||||
|
||||
typedef struct ParallelMempoolState {
|
||||
struct ParallelMempoolState {
|
||||
void *userdata;
|
||||
TaskParallelMempoolFunc func;
|
||||
} ParallelMempoolState;
|
||||
};
|
||||
|
||||
static void parallel_mempool_func(TaskPool *__restrict pool, void *taskdata)
|
||||
{
|
||||
ParallelMempoolState *__restrict state = BLI_task_pool_user_data(pool);
|
||||
ParallelMempoolState *__restrict state = static_cast<ParallelMempoolState *>(
|
||||
BLI_task_pool_user_data(pool));
|
||||
BLI_mempool_threadsafe_iter *iter = &((ParallelMempoolTaskData *)taskdata)->ts_iter;
|
||||
TaskParallelTLS *tls = &((ParallelMempoolTaskData *)taskdata)->tls;
|
||||
|
||||
MempoolIterData *item;
|
||||
while ((item = mempool_iter_threadsafe_step(iter)) != NULL) {
|
||||
while ((item = static_cast<MempoolIterData *>(mempool_iter_threadsafe_step(iter))) != nullptr) {
|
||||
state->func(state->userdata, item, tls);
|
||||
}
|
||||
}
|
||||
@@ -63,13 +63,13 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
|
||||
|
||||
void *userdata_chunk = settings->userdata_chunk;
|
||||
const size_t userdata_chunk_size = settings->userdata_chunk_size;
|
||||
void *userdata_chunk_array = NULL;
|
||||
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != NULL);
|
||||
void *userdata_chunk_array = nullptr;
|
||||
const bool use_userdata_chunk = (userdata_chunk_size != 0) && (userdata_chunk != nullptr);
|
||||
|
||||
if (!settings->use_threading) {
|
||||
TaskParallelTLS tls = {NULL};
|
||||
TaskParallelTLS tls = {nullptr};
|
||||
if (use_userdata_chunk) {
|
||||
if (settings->func_init != NULL) {
|
||||
if (settings->func_init != nullptr) {
|
||||
settings->func_init(userdata, userdata_chunk);
|
||||
}
|
||||
tls.userdata_chunk = userdata_chunk;
|
||||
@@ -80,11 +80,11 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
|
||||
|
||||
void *item;
|
||||
while ((item = BLI_mempool_iterstep(&iter))) {
|
||||
func(userdata, item, &tls);
|
||||
func(userdata, static_cast<MempoolIterData *>(item), &tls);
|
||||
}
|
||||
|
||||
if (use_userdata_chunk) {
|
||||
if (settings->func_free != NULL && userdata_chunk != NULL) {
|
||||
if (settings->func_free != nullptr && userdata_chunk != nullptr) {
|
||||
/* `func_free` should only free data that was created during execution of `func`. */
|
||||
settings->func_free(userdata, userdata_chunk);
|
||||
}
|
||||
@@ -114,31 +114,32 @@ void BLI_task_parallel_mempool(BLI_mempool *mempool,
|
||||
mempool, (size_t)tasks_num);
|
||||
|
||||
for (int i = 0; i < tasks_num; i++) {
|
||||
void *userdata_chunk_local = NULL;
|
||||
void *userdata_chunk_local = nullptr;
|
||||
if (use_userdata_chunk) {
|
||||
userdata_chunk_local = (char *)userdata_chunk_array + (userdata_chunk_size * i);
|
||||
memcpy(userdata_chunk_local, userdata_chunk, userdata_chunk_size);
|
||||
if (settings->func_init != NULL) {
|
||||
if (settings->func_init != nullptr) {
|
||||
settings->func_init(userdata, userdata_chunk_local);
|
||||
}
|
||||
}
|
||||
mempool_iterator_data[i].tls.userdata_chunk = userdata_chunk_local;
|
||||
|
||||
/* Use this pool's pre-allocated tasks. */
|
||||
BLI_task_pool_push(task_pool, parallel_mempool_func, &mempool_iterator_data[i], false, NULL);
|
||||
BLI_task_pool_push(
|
||||
task_pool, parallel_mempool_func, &mempool_iterator_data[i], false, nullptr);
|
||||
}
|
||||
|
||||
BLI_task_pool_work_and_wait(task_pool);
|
||||
BLI_task_pool_free(task_pool);
|
||||
|
||||
if (use_userdata_chunk) {
|
||||
if ((settings->func_free != NULL) || (settings->func_reduce != NULL)) {
|
||||
if ((settings->func_free != nullptr) || (settings->func_reduce != nullptr)) {
|
||||
for (int i = 0; i < tasks_num; i++) {
|
||||
if (settings->func_reduce) {
|
||||
settings->func_reduce(
|
||||
userdata, userdata_chunk, mempool_iterator_data[i].tls.userdata_chunk);
|
||||
}
|
||||
if (settings->func_free && mempool_iterator_data[i].tls.userdata_chunk != NULL) {
|
||||
if (settings->func_free && mempool_iterator_data[i].tls.userdata_chunk != nullptr) {
|
||||
settings->func_free(userdata, mempool_iterator_data[i].tls.userdata_chunk);
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,10 @@
|
||||
* Time-Code string formatting
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_string.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLI_timecode.h" /* own include */
|
||||
|
||||
@@ -36,7 +36,7 @@ int BLI_windows_get_executable_dir(char r_dirpath[/*FILE_MAXDIR*/])
|
||||
char dir[FILE_MAX];
|
||||
int a;
|
||||
/* Change to utf support. */
|
||||
GetModuleFileName(NULL, filepath, sizeof(filepath));
|
||||
GetModuleFileName(nullptr, filepath, sizeof(filepath));
|
||||
BLI_path_split_dir_part(filepath, dir, sizeof(dir)); /* shouldn't be relative */
|
||||
a = strlen(dir);
|
||||
if (dir[a - 1] == '\\') {
|
||||
@@ -52,7 +52,7 @@ bool BLI_windows_is_store_install(void)
|
||||
{
|
||||
char install_dir[FILE_MAXDIR];
|
||||
BLI_windows_get_executable_dir(install_dir);
|
||||
return (BLI_strcasestr(install_dir, "\\WindowsApps\\") != NULL);
|
||||
return (BLI_strcasestr(install_dir, "\\WindowsApps\\") != nullptr);
|
||||
}
|
||||
|
||||
static void registry_error(HKEY root, const char *message)
|
||||
@@ -92,12 +92,19 @@ static bool register_blender_prog_id(const char *prog_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
lresult = RegCreateKeyEx(
|
||||
root, prog_id, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_progid, &dwd);
|
||||
lresult = RegCreateKeyEx(root,
|
||||
prog_id,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&hkey_progid,
|
||||
&dwd);
|
||||
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
lresult = RegSetValueEx(
|
||||
hkey_progid, NULL, 0, REG_SZ, (BYTE *)friendly_name, strlen(friendly_name) + 1);
|
||||
hkey_progid, nullptr, 0, REG_SZ, (BYTE *)friendly_name, strlen(friendly_name) + 1);
|
||||
}
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
lresult = RegSetValueEx(
|
||||
@@ -109,20 +116,34 @@ static bool register_blender_prog_id(const char *prog_id,
|
||||
}
|
||||
|
||||
SNPRINTF(buffer, "%s\\shell\\open", prog_id);
|
||||
lresult = RegCreateKeyEx(
|
||||
root, buffer, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_progid, &dwd);
|
||||
lresult = RegCreateKeyEx(root,
|
||||
buffer,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&hkey_progid,
|
||||
&dwd);
|
||||
|
||||
lresult = RegSetValueEx(
|
||||
hkey_progid, "FriendlyAppName", 0, REG_SZ, (BYTE *)friendly_name, strlen(friendly_name) + 1);
|
||||
|
||||
SNPRINTF(buffer, "%s\\shell\\open\\command", prog_id);
|
||||
|
||||
lresult = RegCreateKeyEx(
|
||||
root, buffer, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_progid, &dwd);
|
||||
lresult = RegCreateKeyEx(root,
|
||||
buffer,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&hkey_progid,
|
||||
&dwd);
|
||||
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
SNPRINTF(buffer, "\"%s\" \"%%1\"", executable);
|
||||
lresult = RegSetValueEx(hkey_progid, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
lresult = RegSetValueEx(hkey_progid, nullptr, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
RegCloseKey(hkey_progid);
|
||||
}
|
||||
if (lresult != ERROR_SUCCESS) {
|
||||
@@ -131,12 +152,19 @@ static bool register_blender_prog_id(const char *prog_id,
|
||||
}
|
||||
|
||||
SNPRINTF(buffer, "%s\\DefaultIcon", prog_id);
|
||||
lresult = RegCreateKeyEx(
|
||||
root, buffer, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey_progid, &dwd);
|
||||
lresult = RegCreateKeyEx(root,
|
||||
buffer,
|
||||
0,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
nullptr,
|
||||
&hkey_progid,
|
||||
&dwd);
|
||||
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
SNPRINTF(buffer, "\"%s\", 1", executable);
|
||||
lresult = RegSetValueEx(hkey_progid, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
lresult = RegSetValueEx(hkey_progid, nullptr, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1);
|
||||
RegCloseKey(hkey_progid);
|
||||
}
|
||||
if (lresult != ERROR_SUCCESS) {
|
||||
@@ -185,10 +213,10 @@ bool BLI_windows_register_blend_extension(const bool all_users)
|
||||
}
|
||||
|
||||
lresult = RegCreateKeyEx(
|
||||
root, ".blend", 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
|
||||
root, ".blend", 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &hkey, &dwd);
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
/* Set this instance the default. */
|
||||
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)prog_id, strlen(prog_id) + 1);
|
||||
lresult = RegSetValueEx(hkey, nullptr, 0, REG_SZ, (BYTE *)prog_id, strlen(prog_id) + 1);
|
||||
|
||||
if (lresult != ERROR_SUCCESS) {
|
||||
registry_error(root, "Unable to register Blend document type");
|
||||
@@ -200,10 +228,10 @@ bool BLI_windows_register_blend_extension(const bool all_users)
|
||||
lresult = RegCreateKeyEx(root,
|
||||
".blend\\OpenWithProgids",
|
||||
0,
|
||||
NULL,
|
||||
nullptr,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS,
|
||||
NULL,
|
||||
nullptr,
|
||||
&hkey,
|
||||
&dwd);
|
||||
|
||||
@@ -212,7 +240,7 @@ bool BLI_windows_register_blend_extension(const bool all_users)
|
||||
RegCloseKey(hkey);
|
||||
return false;
|
||||
}
|
||||
lresult = RegSetValueEx(hkey, prog_id, 0, REG_NONE, NULL, 0);
|
||||
lresult = RegSetValueEx(hkey, prog_id, 0, REG_NONE, nullptr, 0);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
@@ -272,9 +300,9 @@ bool BLI_windows_unregister_blend_extension(const bool all_users)
|
||||
if (lresult == ERROR_SUCCESS) {
|
||||
char buffer[256] = {0};
|
||||
DWORD size = sizeof(buffer);
|
||||
lresult = RegGetValueA(hkey, NULL, NULL, RRF_RT_REG_SZ, NULL, &buffer, &size);
|
||||
lresult = RegGetValueA(hkey, nullptr, nullptr, RRF_RT_REG_SZ, nullptr, &buffer, &size);
|
||||
if (lresult == ERROR_SUCCESS && STREQ(buffer, BLENDER_WIN_APPID)) {
|
||||
RegSetValueEx(hkey, NULL, 0, REG_SZ, 0, 0);
|
||||
RegSetValueEx(hkey, nullptr, 0, REG_SZ, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,13 +402,13 @@ bool BLI_windows_execute_self(const char *parameters,
|
||||
SHELLEXECUTEINFOA shellinfo = {0};
|
||||
shellinfo.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
shellinfo.fMask = wait ? SEE_MASK_NOCLOSEPROCESS : SEE_MASK_DEFAULT;
|
||||
shellinfo.hwnd = NULL;
|
||||
shellinfo.lpVerb = elevated ? "runas" : NULL;
|
||||
shellinfo.hwnd = nullptr;
|
||||
shellinfo.lpVerb = elevated ? "runas" : nullptr;
|
||||
shellinfo.lpFile = blender_path;
|
||||
shellinfo.lpParameters = parameters;
|
||||
shellinfo.lpDirectory = NULL;
|
||||
shellinfo.lpDirectory = nullptr;
|
||||
shellinfo.nShow = silent ? SW_HIDE : SW_SHOW;
|
||||
shellinfo.hInstApp = NULL;
|
||||
shellinfo.hInstApp = nullptr;
|
||||
shellinfo.hProcess = 0;
|
||||
|
||||
DWORD exitCode = 0;
|
||||
@@ -417,7 +445,7 @@ void BLI_windows_get_default_root_dir(char root[4])
|
||||
else {
|
||||
/* if GetWindowsDirectory fails, something has probably gone wrong,
|
||||
* we are trying the blender install dir though */
|
||||
if (GetModuleFileName(NULL, str, MAX_PATH + 1)) {
|
||||
if (GetModuleFileName(nullptr, str, MAX_PATH + 1)) {
|
||||
printf(
|
||||
"Error! Could not get the Windows Directory - "
|
||||
"Defaulting to Blender installation Dir!\n");
|
||||
@@ -461,8 +489,8 @@ void BLI_windows_get_default_root_dir(char root[4])
|
||||
bool BLI_windows_get_directx_driver_version(const wchar_t *deviceSubString,
|
||||
long long *r_driverVersion)
|
||||
{
|
||||
IDXGIFactory *pFactory = NULL;
|
||||
IDXGIAdapter *pAdapter = NULL;
|
||||
IDXGIFactory *pFactory = nullptr;
|
||||
IDXGIAdapter *pAdapter = nullptr;
|
||||
if (CreateDXGIFactory(__uuidof(IDXGIFactory), (void **)&pFactory) == S_OK) {
|
||||
for (UINT i = 0; pFactory->EnumAdapters(i, &pAdapter) != DXGI_ERROR_NOT_FOUND; ++i) {
|
||||
LARGE_INTEGER version;
|
||||
|
||||
@@ -53,7 +53,7 @@ DIR *opendir(const char *path)
|
||||
{
|
||||
wchar_t *path_16 = alloc_utf16_from_8(path, 0);
|
||||
int path_len;
|
||||
DIR *newd = NULL;
|
||||
DIR *newd = nullptr;
|
||||
|
||||
if ((GetFileAttributesW(path_16) & FILE_ATTRIBUTE_DIRECTORY) &&
|
||||
((path_len = strlen(path)) < (sizeof(newd->path) - PATH_SUFFIX_LEN)))
|
||||
@@ -66,7 +66,7 @@ DIR *opendir(const char *path)
|
||||
newd->direntry.d_ino = 0;
|
||||
newd->direntry.d_off = 0;
|
||||
newd->direntry.d_reclen = 0;
|
||||
newd->direntry.d_name = NULL;
|
||||
newd->direntry.d_name = nullptr;
|
||||
}
|
||||
|
||||
free(path_16);
|
||||
@@ -76,9 +76,9 @@ DIR *opendir(const char *path)
|
||||
static char *BLI_alloc_utf_8_from_16(wchar_t *in16, size_t add)
|
||||
{
|
||||
size_t bsize = count_utf_8_from_16(in16);
|
||||
char *out8 = NULL;
|
||||
char *out8 = nullptr;
|
||||
if (!bsize) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
out8 = (char *)MEM_mallocN(sizeof(char) * (bsize + add), "UTF-8 String");
|
||||
conv_utf_16_to_8(in16, out8, bsize);
|
||||
@@ -88,9 +88,9 @@ static char *BLI_alloc_utf_8_from_16(wchar_t *in16, size_t add)
|
||||
static wchar_t *UNUSED_FUNCTION(BLI_alloc_utf16_from_8)(char *in8, size_t add)
|
||||
{
|
||||
size_t bsize = count_utf_16_from_8(in8);
|
||||
wchar_t *out16 = NULL;
|
||||
wchar_t *out16 = nullptr;
|
||||
if (!bsize) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
out16 = (wchar_t *)MEM_mallocN(sizeof(wchar_t) * (bsize + add), "UTF-16 String");
|
||||
conv_utf_8_to_16(in8, out16, bsize);
|
||||
@@ -101,7 +101,7 @@ struct dirent *readdir(DIR *dp)
|
||||
{
|
||||
if (dp->direntry.d_name) {
|
||||
MEM_freeN(dp->direntry.d_name);
|
||||
dp->direntry.d_name = NULL;
|
||||
dp->direntry.d_name = nullptr;
|
||||
}
|
||||
|
||||
if (dp->handle == INVALID_HANDLE_VALUE) {
|
||||
@@ -109,7 +109,7 @@ struct dirent *readdir(DIR *dp)
|
||||
dp->handle = FindFirstFileW(path_16, &(dp->data));
|
||||
free(path_16);
|
||||
if (dp->handle == INVALID_HANDLE_VALUE) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
dp->direntry.d_name = BLI_alloc_utf_8_from_16(dp->data.cFileName, 0);
|
||||
@@ -122,7 +122,7 @@ struct dirent *readdir(DIR *dp)
|
||||
return &dp->direntry;
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,8 @@ bool BLI_windows_update_pinned_launcher(const char *launcher_path)
|
||||
|
||||
LPWSTR quick_launch_folder_path;
|
||||
if (SHGetKnownFolderPath(
|
||||
FOLDERID_ImplicitAppShortcuts, KF_FLAG_DEFAULT, NULL, &quick_launch_folder_path) != S_OK)
|
||||
FOLDERID_ImplicitAppShortcuts, KF_FLAG_DEFAULT, nullptr, &quick_launch_folder_path) !=
|
||||
S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -62,7 +63,8 @@ bool BLI_windows_update_pinned_launcher(const char *launcher_path)
|
||||
for (auto const &dir_entry : std::filesystem::recursive_directory_iterator(search_path)) {
|
||||
|
||||
Microsoft::WRL::ComPtr<IShellLinkW> shell_link;
|
||||
if (CoCreateInstance(__uuidof(ShellLink), NULL, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) != S_OK)
|
||||
if (CoCreateInstance(__uuidof(ShellLink), nullptr, CLSCTX_ALL, IID_PPV_ARGS(&shell_link)) !=
|
||||
S_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -87,7 +89,7 @@ bool BLI_windows_update_pinned_launcher(const char *launcher_path)
|
||||
if (property_store->GetValue(PKEY_AppUserModel_ID, &app_model) == S_OK) {
|
||||
if (app_model.vt == VT_LPWSTR && std::wstring(BLENDER_WIN_APPID_16) == app_model.pwszVal) {
|
||||
shell_link->SetPath(launcher_path_w);
|
||||
persist_file->Save(NULL, TRUE);
|
||||
persist_file->Save(nullptr, TRUE);
|
||||
}
|
||||
}
|
||||
PropVariantClear(&app_model);
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#include "BLI_math_bits.h"
|
||||
#include "BLI_sys_types.h"
|
||||
#include "testing/testing.h"
|
||||
#include <iostream>
|
||||
|
||||
TEST(math_bits, BitscanReverseClearUint)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BLI_listbase.h"
|
||||
#include "BLI_utildefines.h"
|
||||
#include "DNA_listBase.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct ID;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ set(LIB
|
||||
|
||||
add_definitions(-DWITH_DNA_GHASH)
|
||||
|
||||
# Needed for `mallocn.c`.
|
||||
# Needed for `mallocn.cc`.
|
||||
if(HAVE_MALLOC_STATS_H)
|
||||
add_definitions(-DHAVE_MALLOC_STATS_H)
|
||||
endif()
|
||||
@@ -47,23 +47,23 @@ file(GENERATE OUTPUT ${dna_header_string_file} CONTENT "${DNA_FILE_LIST}")
|
||||
|
||||
# Subset of `blenlib` used by `makesdna`.
|
||||
set(BLENLIB_SRC
|
||||
../../blenlib/intern/BLI_assert.c
|
||||
../../blenlib/intern/BLI_ghash.c
|
||||
../../blenlib/intern/BLI_assert.cc
|
||||
../../blenlib/intern/BLI_ghash.cc
|
||||
../../blenlib/intern/BLI_ghash_utils.cc
|
||||
../../blenlib/intern/BLI_linklist.c
|
||||
../../blenlib/intern/BLI_memarena.c
|
||||
../../blenlib/intern/BLI_mempool.c
|
||||
../../blenlib/intern/endian_switch.c
|
||||
../../blenlib/intern/BLI_linklist.cc
|
||||
../../blenlib/intern/BLI_memarena.cc
|
||||
../../blenlib/intern/BLI_mempool.cc
|
||||
../../blenlib/intern/endian_switch.cc
|
||||
../../blenlib/intern/listbase.cc
|
||||
../../blenlib/intern/string.c
|
||||
../../blenlib/intern/string.cc
|
||||
|
||||
# Dependency of BLI_ghash.c
|
||||
# Dependency of BLI_ghash.cc
|
||||
../../blenlib/intern/hash_mm2a.cc
|
||||
|
||||
# Dependencies of BLI_mempool.c when ASAN is enabled.
|
||||
../../blenlib/intern/gsqueue.c
|
||||
# Dependencies of BLI_mempool.cc when ASAN is enabled.
|
||||
../../blenlib/intern/gsqueue.cc
|
||||
../../blenlib/intern/threads.cc
|
||||
../../blenlib/intern/time.c
|
||||
../../blenlib/intern/time.cc
|
||||
)
|
||||
|
||||
set(SRC
|
||||
@@ -74,7 +74,7 @@ set(SRC
|
||||
${dna_header_string_file}
|
||||
)
|
||||
|
||||
# BLI_mempool.c needs these files for ThreadMutex when
|
||||
# BLI_mempool.cc needs these files for ThreadMutex when
|
||||
# compiling in address sanitizer mode.
|
||||
if(WITH_COMPILER_ASAN)
|
||||
list(APPEND SRC
|
||||
|
||||
@@ -72,7 +72,6 @@
|
||||
#include "BLI_endian_switch.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_rotation.h"
|
||||
#include "BLI_memarena.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "IMB_imbuf_enums.h"
|
||||
|
||||
Reference in New Issue
Block a user