src/array_list.c

changeset 807
c8d692131b1e
parent 804
5136f2fc32ec
child 817
949908c97474
equal deleted inserted replaced
806:e06249e09f99 807:c8d692131b1e
104 } 104 }
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 unsigned cx_array_swap_sbo_size = CX_ARRAY_SWAP_SBO_SIZE;
110 bool CX_DISABLE_ARRAY_LIST_SWAP_SBO = false;
111 110
112 void cx_array_swap( 111 void cx_array_swap(
113 void *arr, 112 void *arr,
114 size_t elem_size, 113 size_t elem_size,
115 size_t idx1, 114 size_t idx1,
122 121
123 char sbo_mem[CX_ARRAY_SWAP_SBO_SIZE]; 122 char sbo_mem[CX_ARRAY_SWAP_SBO_SIZE];
124 void *tmp; 123 void *tmp;
125 124
126 // decide if we can use the local buffer 125 // decide if we can use the local buffer
127 if (elem_size > CX_ARRAY_SWAP_SBO_SIZE || CX_DISABLE_ARRAY_LIST_SWAP_SBO) { 126 if (elem_size > CX_ARRAY_SWAP_SBO_SIZE) {
128 tmp = malloc(elem_size); 127 tmp = malloc(elem_size);
129 // we don't want to enforce error handling 128 // we don't want to enforce error handling
130 if (tmp == NULL) abort(); 129 if (tmp == NULL) abort();
131 } else { 130 } else {
132 tmp = sbo_mem; 131 tmp = sbo_mem;

mercurial