src/array_list.c

changeset 804
5136f2fc32ec
parent 764
ccbdbd088455
child 807
c8d692131b1e
equal deleted inserted replaced
803:0711d869ce4d 804:5136f2fc32ec
105 105
106 #ifndef CX_ARRAY_SWAP_SBO_SIZE 106 #ifndef CX_ARRAY_SWAP_SBO_SIZE
107 #define CX_ARRAY_SWAP_SBO_SIZE 128 107 #define CX_ARRAY_SWAP_SBO_SIZE 128
108 #endif 108 #endif
109 109
110 bool CX_DISABLE_ARRAY_LIST_SWAP_SBO = false;
111
110 void cx_array_swap( 112 void cx_array_swap(
111 void *arr, 113 void *arr,
112 size_t elem_size, 114 size_t elem_size,
113 size_t idx1, 115 size_t idx1,
114 size_t idx2 116 size_t idx2
120 122
121 char sbo_mem[CX_ARRAY_SWAP_SBO_SIZE]; 123 char sbo_mem[CX_ARRAY_SWAP_SBO_SIZE];
122 void *tmp; 124 void *tmp;
123 125
124 // decide if we can use the local buffer 126 // decide if we can use the local buffer
125 if (elem_size > CX_ARRAY_SWAP_SBO_SIZE) { 127 if (elem_size > CX_ARRAY_SWAP_SBO_SIZE || CX_DISABLE_ARRAY_LIST_SWAP_SBO) {
126 tmp = malloc(elem_size); 128 tmp = malloc(elem_size);
127 // we don't want to enforce error handling 129 // we don't want to enforce error handling
128 if (tmp == NULL) abort(); 130 if (tmp == NULL) abort();
129 } else { 131 } else {
130 tmp = sbo_mem; 132 tmp = sbo_mem;

mercurial