BLI_array_growone wasn't always returning the new size. also some formatting edits
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
/**
|
||||
* Array Library
|
||||
*
|
||||
/*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
@@ -28,32 +26,32 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
this library needs to be changed to not use macros quite so heavily,
|
||||
and to be more of a complete array API. The way arrays are
|
||||
exposed to client code as normal C arrays is very useful though, imho.
|
||||
it does require some use of macros, however.
|
||||
|
||||
anyway, it's used a bit too heavily to simply rewrite as a
|
||||
more "correct" solution without macros entirely. I originally wrote this
|
||||
to be very easy to use, without the normal pain of most array libraries.
|
||||
This was especially helpful when it came to the massive refactors necessary for
|
||||
bmesh, and really helped to speed the process up. - joeedh
|
||||
|
||||
little array macro library. example of usage:
|
||||
|
||||
int *arr = NULL;
|
||||
BLI_array_declare(arr);
|
||||
int i;
|
||||
|
||||
for (i=0; i<10; i++) {
|
||||
BLI_array_growone(arr);
|
||||
arr[i] = something;
|
||||
}
|
||||
BLI_array_free(arr);
|
||||
|
||||
arrays are buffered, using double-buffering (so on each reallocation,
|
||||
the array size is doubled). supposedly this should give good Big Oh
|
||||
behaviour, though it may not be the best in practice.
|
||||
* this library needs to be changed to not use macros quite so heavily,
|
||||
* and to be more of a complete array API. The way arrays are
|
||||
* exposed to client code as normal C arrays is very useful though, imho.
|
||||
* it does require some use of macros, however.
|
||||
*
|
||||
* anyway, it's used a bit too heavily to simply rewrite as a
|
||||
* more "correct" solution without macros entirely. I originally wrote this
|
||||
* to be very easy to use, without the normal pain of most array libraries.
|
||||
* This was especially helpful when it came to the massive refactors necessary
|
||||
* for bmesh, and really helped to speed the process up. - joeedh
|
||||
*
|
||||
* little array macro library. example of usage:
|
||||
*
|
||||
* int *arr = NULL;
|
||||
* BLI_array_declare(arr);
|
||||
* int i;
|
||||
*
|
||||
* for (i=0; i<10; i++) {
|
||||
* BLI_array_growone(arr);
|
||||
* arr[i] = something;
|
||||
* }
|
||||
* BLI_array_free(arr);
|
||||
*
|
||||
* arrays are buffered, using double-buffering (so on each reallocation,
|
||||
* the array size is doubled). supposedly this should give good Big Oh
|
||||
* behaviour, though it may not be the best in practice.
|
||||
*/
|
||||
|
||||
#define BLI_array_declare(arr) \
|
||||
@@ -78,7 +76,7 @@ behaviour, though it may not be the best in practice.
|
||||
|
||||
|
||||
#define BLI_array_totalsize(arr) ( \
|
||||
(signed int) \
|
||||
(size_t) \
|
||||
(((void *)(arr) == (void *)_##arr##_static && (void *)(arr) != NULL) ? \
|
||||
(sizeof(_##arr##_static) / sizeof(*arr)) : \
|
||||
BLI_array_totalsize_dyn(arr)) \
|
||||
@@ -108,7 +106,7 @@ behaviour, though it may not be the best in practice.
|
||||
), \
|
||||
(void) (arr = _##arr##_tmp \
|
||||
), \
|
||||
_##arr##_count++ \
|
||||
++_##arr##_count \
|
||||
) \
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user