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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-17 07:17:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-17 07:21:24 +0300
commite12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch)
tree8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/blenlib/BLI_buffer.h
parentb3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff)
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211. For details on usage and instructions for migrating branches without conflicts, see: https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/blenlib/BLI_buffer.h')
-rw-r--r--source/blender/blenlib/BLI_buffer.h95
1 files changed, 44 insertions, 51 deletions
diff --git a/source/blender/blenlib/BLI_buffer.h b/source/blender/blenlib/BLI_buffer.h
index 6c3d5cb4350..9f3644ed45a 100644
--- a/source/blender/blenlib/BLI_buffer.h
+++ b/source/blender/blenlib/BLI_buffer.h
@@ -22,60 +22,51 @@
*/
typedef struct {
- void *data;
- const size_t elem_size;
- size_t count, alloc_count;
- int flag;
+ void *data;
+ const size_t elem_size;
+ size_t count, alloc_count;
+ int flag;
} BLI_Buffer;
enum {
- BLI_BUFFER_NOP = 0,
- BLI_BUFFER_USE_STATIC = (1 << 0),
+ BLI_BUFFER_NOP = 0,
+ BLI_BUFFER_USE_STATIC = (1 << 0),
};
#define BLI_buffer_declare_static(type_, name_, flag_, static_count_) \
- char name_ ## user; /* warn for free only */ \
- type_ name_ ## _static_[static_count_]; \
- BLI_Buffer name_ = { \
- (name_ ## _static_), \
- sizeof(type_), \
- 0, \
- static_count_, \
- BLI_BUFFER_USE_STATIC | (flag_)}
+ char name_##user; /* warn for free only */ \
+ type_ name_##_static_[static_count_]; \
+ BLI_Buffer name_ = { \
+ (name_##_static_), sizeof(type_), 0, static_count_, BLI_BUFFER_USE_STATIC | (flag_)}
/* never use static*/
#define BLI_buffer_declare(type_, name_, flag_) \
- bool name_ ## user; /* warn for free only */ \
- BLI_Buffer name_ = { \
- NULL, \
- sizeof(type_), \
- 0, \
- 0, \
- (flag_)}
-
-#define BLI_buffer_at(buffer_, type_, index_) ( \
- (((type_ *)(buffer_)->data)[ \
- (BLI_assert(sizeof(type_) == (buffer_)->elem_size)), \
- (BLI_assert((int)(index_) >= 0 && (size_t)(index_) < (buffer_)->count)), \
- index_]))
-
-#define BLI_buffer_array(buffer_, type_) ( \
- &(BLI_buffer_at(buffer_, type_, 0)))
-
-#define BLI_buffer_resize_data(buffer_, type_, new_count_) ( \
- (BLI_buffer_resize(buffer_, new_count_), new_count_ ? BLI_buffer_array(buffer_, type_) : NULL))
-
-#define BLI_buffer_reinit_data(buffer_, type_, new_count_) ( \
- (BLI_buffer_reinit(buffer_, new_count_), new_count_ ? BLI_buffer_array(buffer_, type_) : NULL))
-
-#define BLI_buffer_append(buffer_, type_, val_) ( \
- BLI_buffer_resize(buffer_, (buffer_)->count + 1), \
- (BLI_buffer_at(buffer_, type_, (buffer_)->count - 1) = val_) \
-)
-
-#define BLI_buffer_clear(buffer_) { \
- (buffer_)->count = 0; \
-} (void)0
+ bool name_##user; /* warn for free only */ \
+ BLI_Buffer name_ = {NULL, sizeof(type_), 0, 0, (flag_)}
+
+#define BLI_buffer_at(buffer_, type_, index_) \
+ ((((type_ *)(buffer_) \
+ ->data)[(BLI_assert(sizeof(type_) == (buffer_)->elem_size)), \
+ (BLI_assert((int)(index_) >= 0 && (size_t)(index_) < (buffer_)->count)), \
+ index_]))
+
+#define BLI_buffer_array(buffer_, type_) (&(BLI_buffer_at(buffer_, type_, 0)))
+
+#define BLI_buffer_resize_data(buffer_, type_, new_count_) \
+ ((BLI_buffer_resize(buffer_, new_count_), new_count_ ? BLI_buffer_array(buffer_, type_) : NULL))
+
+#define BLI_buffer_reinit_data(buffer_, type_, new_count_) \
+ ((BLI_buffer_reinit(buffer_, new_count_), new_count_ ? BLI_buffer_array(buffer_, type_) : NULL))
+
+#define BLI_buffer_append(buffer_, type_, val_) \
+ (BLI_buffer_resize(buffer_, (buffer_)->count + 1), \
+ (BLI_buffer_at(buffer_, type_, (buffer_)->count - 1) = val_))
+
+#define BLI_buffer_clear(buffer_) \
+ { \
+ (buffer_)->count = 0; \
+ } \
+ (void)0
/* Never decreases the amount of memory allocated */
void BLI_buffer_resize(BLI_Buffer *buffer, const size_t new_count);
@@ -85,9 +76,11 @@ void BLI_buffer_reinit(BLI_Buffer *buffer, const size_t new_count);
/* Does not free the buffer structure itself */
void _bli_buffer_free(BLI_Buffer *buffer);
-#define BLI_buffer_free(name_) { \
- _bli_buffer_free(name_); \
- (void)name_ ## user; /* ensure we free */ \
-} (void)0
-
-#endif /* __BLI_BUFFER_H__ */
+#define BLI_buffer_free(name_) \
+ { \
+ _bli_buffer_free(name_); \
+ (void)name_##user; /* ensure we free */ \
+ } \
+ (void)0
+
+#endif /* __BLI_BUFFER_H__ */