[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53504] trunk/blender/source/blender/ blenlib/BLI_buffer.h: add assert to BLI_buffer_at if a type is given different to 'elem_size'
Campbell Barton
ideasman42 at gmail.com
Wed Jan 2 06:20:07 CET 2013
Revision: 53504
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53504
Author: campbellbarton
Date: 2013-01-02 05:19:55 +0000 (Wed, 02 Jan 2013)
Log Message:
-----------
add assert to BLI_buffer_at if a type is given different to 'elem_size'
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_buffer.h
Modified: trunk/blender/source/blender/blenlib/BLI_buffer.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_buffer.h 2013-01-02 05:00:02 UTC (rev 53503)
+++ trunk/blender/source/blender/blenlib/BLI_buffer.h 2013-01-02 05:19:55 UTC (rev 53504)
@@ -72,14 +72,15 @@
0, \
flag_}
-#define BLI_buffer_at(buffer_, type_, index_) \
- (((type_*)(buffer_)->data)[index_])
-#define BLI_buffer_append(buffer_, type_, val_) { \
- BLI_buffer_resize(buffer_, (buffer_)->count + 1); \
- BLI_buffer_at(buffer_, type_, (buffer_)->count - 1) = val_; \
-} (void)0
+#define BLI_buffer_at(buffer_, type_, index_) ( \
+ (((type_ *)(buffer_)->data)[(BLI_assert(sizeof(type_) == (buffer_)->elem_size)), index_]))
+#define BLI_buffer_append(buffer_, type_, val_) ( \
+ BLI_buffer_resize(buffer_, (buffer_)->count + 1), \
+ (BLI_buffer_at(buffer_, type_, (buffer_)->count - 1) = val_) \
+)
+
/* Never decreases the amount of memory allocated */
void BLI_buffer_resize(BLI_Buffer *buffer, int new_count);
More information about the Bf-blender-cvs
mailing list