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>2015-02-13 23:28:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-02-14 00:00:41 +0300
commit7a977df6d4763033388d27453ccf502d00fcf23c (patch)
tree93e237b7b605a948f15a382ddf0b8f9313ceee01 /source/blender/blenlib/intern/BLI_array.c
parent2af905391d6c5e238751b0dd4ce9f766668fcea2 (diff)
Refactor array_utils out of BLI_array
BLI_array.h is for resizing array macros, where as array_utils can operate on any arrays.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_array.c')
-rw-r--r--source/blender/blenlib/intern/BLI_array.c57
1 files changed, 2 insertions, 55 deletions
diff --git a/source/blender/blenlib/intern/BLI_array.c b/source/blender/blenlib/intern/BLI_array.c
index da2eef8ab6a..01550ad1008 100644
--- a/source/blender/blenlib/intern/BLI_array.c
+++ b/source/blender/blenlib/intern/BLI_array.c
@@ -43,6 +43,7 @@
*
* little array macro library. example of usage:
*
+ * \code{.c}
* int *arr = NULL;
* BLI_array_declare(arr);
* int i;
@@ -52,6 +53,7 @@
* arr[i] = something;
* }
* BLI_array_free(arr);
+ * \endcode
*
* arrays are buffered, using double-buffering (so on each reallocation,
* the array size is doubled). supposedly this should give good Big Oh
@@ -59,13 +61,10 @@
*/
#include <string.h>
-#include <stdlib.h>
#include "BLI_array.h"
#include "BLI_sys_types.h"
-#include "BLI_utildefines.h"
-#include "BLI_alloca.h"
#include "MEM_guardedalloc.h"
@@ -100,55 +99,3 @@ void _bli_array_grow_func(void **arr_p, const void *arr_static,
arr_count += num;
#endif
}
-
-void _bli_array_reverse(void *arr_v, unsigned int arr_len, size_t arr_stride)
-{
- const unsigned int arr_half_stride = (arr_len / 2) * arr_stride;
- unsigned int i, i_end;
- char *arr = arr_v;
- char *buf = BLI_array_alloca(buf, arr_stride);
-
- for (i = 0, i_end = (arr_len - 1) * arr_stride;
- i < arr_half_stride;
- i += arr_stride, i_end -= arr_stride)
- {
- memcpy(buf, &arr[i], arr_stride);
- memcpy(&arr[i], &arr[i_end], arr_stride);
- memcpy(&arr[i_end], buf, arr_stride);
- }
-}
-
-void _bli_array_wrap(void *arr_v, unsigned int arr_len, size_t arr_stride, int dir)
-{
- char *arr = arr_v;
- char *buf = BLI_array_alloca(buf, arr_stride);
-
- if (dir == -1) {
- memcpy(buf, arr, arr_stride);
- memmove(arr, arr + arr_stride, arr_stride * (arr_len - 1));
- memcpy(arr + (arr_stride * (arr_len - 1)), buf, arr_stride);
- }
- else if (dir == 1) {
- memcpy(buf, arr + (arr_stride * (arr_len - 1)), arr_stride);
- memmove(arr + arr_stride, arr, arr_stride * (arr_len - 1));
- memcpy(arr, buf, arr_stride);
- }
- else {
- BLI_assert(0);
- }
-}
-
-/**
- * \note Not efficient, use for error checks/asserts.
- */
-int _bli_array_findindex(const void *arr, unsigned int arr_len, size_t arr_stride, const void *p)
-{
- const char *arr_step = (const char *)arr;
- unsigned int i;
- for (i = 0; i < arr_len; i++, arr_step += arr_stride) {
- if (memcmp(arr_step, p, arr_stride) == 0) {
- return (int)i;
- }
- }
- return -1;
-}