|
11 | 11 | #endif |
12 | 12 |
|
13 | 13 | #define CARRAY_CAPI_ID_STRING "_capi_carray" |
14 | | -#define CARRAY_CAPI_VERSION_MAJOR -2 |
| 14 | +#define CARRAY_CAPI_VERSION_MAJOR 1 |
15 | 15 | #define CARRAY_CAPI_VERSION_MINOR 0 |
16 | 16 | #define CARRAY_CAPI_VERSION_PATCH 0 |
17 | 17 |
|
@@ -77,7 +77,7 @@ enum carray_attr |
77 | 77 |
|
78 | 78 | struct carray_info |
79 | 79 | { |
80 | | - carray_type type; |
| 80 | + carray_type elementType; |
81 | 81 | carray_attr attr; |
82 | 82 | size_t elementSize; |
83 | 83 | size_t elementCount; |
@@ -206,13 +206,55 @@ struct carray_capi |
206 | 206 | * newElementCount - new number of elements. If this is larger than the current |
207 | 207 | * element count, the new elements are uninitialized. |
208 | 208 | * |
209 | | - * shrinkCapacity - flag, if true the capacity is set to the new size. |
| 209 | + * reservePercent - if < 0 the capacity is set to the new size, |
| 210 | + * if == 0 the capacity remains if the new size is smaller |
| 211 | + * than current capacity. |
| 212 | + * if > 0 the capacity gets a reserve of reservePercent percent |
| 213 | + * if capacity needs to be increased. E.g. if reservePercent == 100 |
| 214 | + * the capacity is doubled if newElementCount exceeds the current |
| 215 | + * capacity. |
210 | 216 | * |
211 | 217 | * Returns pointer to the first element in the array. The caller may read |
212 | 218 | * or write newElementCount elements at this pointer. |
213 | 219 | * Returns NULL on failure or if newElementCount == 0. |
214 | 220 | */ |
215 | | - void* (*resizeCarray)(carray* a, size_t newElementCount, int shrinkCapacity); |
| 221 | + void* (*resizeCarray)(carray* a, size_t newElementCount, int reservePercent); |
| 222 | + |
| 223 | + /** |
| 224 | + * Insert Elements. |
| 225 | + * |
| 226 | + * offset - index of the first new element, 0 <= offset <= elementCount |
| 227 | + * insertCount - number of elements to be inserted |
| 228 | + * |
| 229 | + * reservePercent - if < 0 the capacity is set to the new size, |
| 230 | + * if == 0 the capacity remains if the new size is smaller |
| 231 | + * than current capacity. |
| 232 | + * if > 0 the capacity gets a reserve of reservePercent percent |
| 233 | + * if capacity needs to be increased. E.g. if reservePercent == 100 |
| 234 | + * the capacity is doubled if new element count exceeds the current |
| 235 | + * capacity. |
| 236 | + * |
| 237 | + * Returns pointer to the first new element in the array. The caller may write |
| 238 | + * insertCount elements at this pointer. |
| 239 | + * Returns NULL on failure or if insertCount == 0. |
| 240 | + */ |
| 241 | + void* (*insertElements)(carray* a, size_t offset, size_t insertCount, int reservePercent); |
| 242 | + |
| 243 | + /** |
| 244 | + * Insert Elements. |
| 245 | + * |
| 246 | + * offset - index of the first element to be removed, 0 <= offset < elementCount |
| 247 | + * removeCount - number of elements to be removed |
| 248 | + * |
| 249 | + * reservePercent - if < 0 the capacity is set to the new size, |
| 250 | + * if == 0 the capacity remains if the new size is smaller |
| 251 | + * than current capacity. |
| 252 | + * if > 0 the capacity gets a reserve of reservePercent percent |
| 253 | + * if capacity needs to be increased. E.g. if reservePercent == 100 |
| 254 | + * the capacity is doubled if new element count exceeds the current |
| 255 | + * capacity. |
| 256 | + */ |
| 257 | + void (*removeElements)(carray* a, size_t offset, size_t count, int reservePercent); |
216 | 258 | }; |
217 | 259 |
|
218 | 260 | #if CARRAY_CAPI_IMPLEMENT_SET_CAPI |
|
0 commit comments