src/ucx/array.c

Mon, 24 Aug 2020 17:09:16 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Mon, 24 Aug 2020 17:09:16 +0200
branch
config
changeset 257
bfeb015c98a4
parent 254
4784c14aa639
child 260
4779a6fb4fbe
permissions
-rw-r--r--

update server.template to new file format

254
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
4 * Copyright 2019 Mike Becker, Olaf Wintermann All rights reserved.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #define _GNU_SOURCE /* we want to use qsort_r(), if available */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define __STDC_WANT_LIB_EXT1__ 1 /* use qsort_s, if available */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33 #include "ucx/array.h"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #include "ucx/utils.h"
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #include <string.h>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37 #include <stdlib.h>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 #include <errno.h>
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 #ifndef UCX_ARRAY_DISABLE_QSORT
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41 #ifdef __GLIBC__
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 8)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 #define ucx_array_sort_impl qsort_r
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 #endif /* glibc version >= 2.8 */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
45 #elif /* not __GLIBC__ */ defined(__APPLE__) || defined(__FreeBSD__)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 #define ucx_array_sort_impl ucx_qsort_r
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47 #define USE_UCX_QSORT_R
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 #elif /* not (__APPLE || __FreeBSD__) */ defined(__sun)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 #if __STDC_VERSION__ >= 201112L
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 #define ucx_array_sort_impl qsort_s
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 #endif /* __GLIBC__, __APLE__, __FreeBSD__, __sun */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 #endif /* UCX_ARRAY_DISABLE_QSORT */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 #ifndef ucx_array_sort_impl
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56 #define ucx_array_sort_impl ucx_mergesort
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 #endif
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 static int ucx_array_ensurecap(UcxArray *array, size_t reqcap) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
60 size_t required_capacity = array->capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
61 while (reqcap > required_capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
62 if (required_capacity * 2 < required_capacity)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
64 required_capacity <<= 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
66 if (ucx_array_reserve(array, required_capacity)) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72 int ucx_array_util_set_a(UcxAllocator* alloc, void** array, size_t* capacity,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
73 size_t elmsize, size_t index, ...) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
74
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 if(!alloc || !capacity || !array) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76 errno = EINVAL;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80 size_t newcapacity = *capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 while(index >= newcapacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82 if(ucx_szmul(newcapacity, 2, &newcapacity)) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83 errno = EOVERFLOW;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 size_t memlen, offset;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89 if(ucx_szmul(newcapacity, elmsize, &memlen)) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
90 errno = EOVERFLOW;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
91 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
92 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
93 /* we don't need to check index*elmsize - it is smaller than memlen */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
94
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
95
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
96 void* newptr = alrealloc(alloc, *array, memlen);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
97 if(newptr == NULL) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
98 errno = ENOMEM; /* we cannot assume that every allocator sets this */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
99 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
100 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
101 *array = newptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
102 *capacity = newcapacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
103
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
104
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
105 char* dest = *array;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
106 dest += elmsize*index;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
107
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
108 va_list ap;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
109 va_start(ap, index);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
110 int elem = va_arg(ap, int);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
111 memcpy(dest, &elem, elmsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
112 va_end(ap);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
113
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
114 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
115 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
116
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
117 UcxArray* ucx_array_new(size_t capacity, size_t elemsize) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
118 return ucx_array_new_a(capacity, elemsize, ucx_default_allocator());
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
119 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
120
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
121 UcxArray* ucx_array_new_a(size_t capacity, size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
122 UcxAllocator* allocator) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
123 UcxArray* array = almalloc(allocator, sizeof(UcxArray));
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
124 if(array) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
125 ucx_array_init_a(array, capacity, elemsize, allocator);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
126 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
127 return array;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
128 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
129
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
130 void ucx_array_init(UcxArray* array, size_t capacity, size_t elemsize) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
131 ucx_array_init_a(array, capacity, elemsize, ucx_default_allocator());
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
132 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
133
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
134 void ucx_array_init_a(UcxArray* array, size_t capacity, size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
135 UcxAllocator* allocator) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
136
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
137 array->allocator = allocator;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
138 array->elemsize = elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
139 array->size = 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
140 array->data = alcalloc(allocator, capacity, elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
141
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
142 if (array->data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
143 array->capacity = capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
144 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
145 array->capacity = 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
146 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
147 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
148
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
149 int ucx_array_clone(UcxArray* dest, UcxArray const* src) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
150 if (ucx_array_ensurecap(dest, src->capacity)) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
151 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
152 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
153
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
154 dest->elemsize = src->elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
155 dest->size = src->size;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
156
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
157 if (dest->data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
158 memcpy(dest->data, src->data, src->size*src->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
159 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
160
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
161 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
162 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
163
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
164 int ucx_array_equals(UcxArray const *array1, UcxArray const *array2,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
165 cmp_func cmpfnc, void* data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
166
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
167 if (array1->size != array2->size || array1->elemsize != array2->elemsize) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
168 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
169 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
170 if (array1->size == 0)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
171 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
172
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
173 size_t elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
174 if (cmpfnc == NULL) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
175 cmpfnc = ucx_cmp_mem;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
176 elemsize = array1->elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
177 data = &elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
178 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
179
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
180 for (size_t i = 0 ; i < array1->size ; i++) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
181 int r = cmpfnc(
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
182 ucx_array_at(array1, i),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
183 ucx_array_at(array2, i),
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
184 data);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
185 if (r != 0)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
186 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
187 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
188 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
189 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
190 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
191
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
192 void ucx_array_destroy(UcxArray *array) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
193 if(array->data)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
194 alfree(array->allocator, array->data);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
195 array->data = NULL;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
196 array->capacity = array->size = 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
197 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
198
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
199 void ucx_array_free(UcxArray *array) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
200 ucx_array_destroy(array);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
201 alfree(array->allocator, array);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
202 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
203
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
204 int ucx_array_append_from(UcxArray *array, void *data, size_t count) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
205 if (ucx_array_ensurecap(array, array->size + count))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
206 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
207
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
208 void* dest = ucx_array_at(array, array->size);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
209 if (data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
210 memcpy(dest, data, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
211 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
212 memset(dest, 0, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
213 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
214 array->size += count;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
215
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
216 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
217 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
218
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
219 int ucx_array_prepend_from(UcxArray *array, void *data, size_t count) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
220 if (ucx_array_ensurecap(array, array->size + count))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
221 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
222
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
223 if (array->size > 0) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
224 void *dest = ucx_array_at(array, count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
225 memmove(dest, array->data, array->elemsize*array->size);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
226 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
227
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
228 if (data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
229 memcpy(array->data, data, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
230 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
231 memset(array->data, 0, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
232 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
233 array->size += count;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
234
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
235 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
236 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
237
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
238 int ucx_array_set_from(UcxArray *array, size_t index,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
239 void *data, size_t count) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
240 if (ucx_array_ensurecap(array, index + count))
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
241 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
242
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
243 if (index+count > array->size) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
244 array->size = index+count;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
245 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
246
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
247 void *dest = ucx_array_at(array, index);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
248 if (data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
249 memcpy(dest, data, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
250 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
251 memset(dest, 0, array->elemsize*count);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
252 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
253
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
254 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
255 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
256
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
257 int ucx_array_appendv(UcxArray *array, ...) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
258 va_list ap;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
259 va_start(ap, array);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
260 int elem = va_arg(ap, int);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
261 int ret = ucx_array_append_from(array, &elem, 1);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
262 va_end(ap);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
263 return ret;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
264 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
265
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
266 int ucx_array_prependv(UcxArray *array, ...) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
267 va_list ap;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
268 va_start(ap, array);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
269 int elem = va_arg(ap, int);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
270 int ret = ucx_array_prepend_from(array, &elem, 1);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
271 va_end(ap);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
272 return ret;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
273 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
274
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
275 int ucx_array_setv(UcxArray *array, size_t index, ...) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
276 va_list ap;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
277 va_start(ap, index);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
278 int elem = va_arg(ap, int);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
279 int ret = ucx_array_set_from(array, index, &elem, 1);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
280 va_end(ap);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
281 return ret;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
282 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
283
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
284 int ucx_array_concat(UcxArray *array1, const UcxArray *array2) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
285
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
286 if (array1->elemsize != array2->elemsize)
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
287 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
288
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
289 size_t capacity = array1->capacity+array2->capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
290
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
291 if (array1->capacity < capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
292 if (ucx_array_reserve(array1, capacity)) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
293 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
294 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
295 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
296
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
297 void* dest = ucx_array_at(array1, array1->size);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
298 memcpy(dest, array2->data, array2->size*array2->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
299
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
300 array1->size += array2->size;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
301
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
302 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
303 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
304
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
305 void *ucx_array_at(UcxArray const *array, size_t index) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
306 char* memory = array->data;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
307 char* loc = memory + index*array->elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
308 return loc;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
309 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
310
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
311 size_t ucx_array_find(UcxArray const *array, void *elem,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
312 cmp_func cmpfnc, void *data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
313
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
314 size_t elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
315 if (cmpfnc == NULL) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
316 cmpfnc = ucx_cmp_mem;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
317 elemsize = array->elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
318 data = &elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
319 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
320
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
321 if (array->size > 0) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
322 for (size_t i = 0 ; i < array->size ; i++) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
323 void* ptr = ucx_array_at(array, i);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
324 if (cmpfnc(ptr, elem, data) == 0) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
325 return i;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
326 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
327 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
328 return array->size;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
329 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
330 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
331 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
332 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
333
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
334 int ucx_array_contains(UcxArray const *array, void *elem,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
335 cmp_func cmpfnc, void *data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
336 return ucx_array_find(array, elem, cmpfnc, data) != array->size;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
337 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
338
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
339 static void ucx_mergesort_merge(void *arrdata,size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
340 cmp_func cmpfnc, void *data,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
341 size_t start, size_t mid, size_t end) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
342
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
343 char* array = arrdata;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
344
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
345 size_t rightstart = mid + 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
346
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
347 if (cmpfnc(array + mid*elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
348 array + rightstart*elemsize, data) <= 0) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
349 /* already sorted */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
350 return;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
351 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
352
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
353 /* we need memory for one element */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
354 void *value = malloc(elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
355
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
356 while (start <= mid && rightstart <= end) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
357 if (cmpfnc(array + start*elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
358 array + rightstart*elemsize, data) <= 0) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
359 start++;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
360 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
361 /* save the value from the right */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
362 memcpy(value, array + rightstart*elemsize, elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
363
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
364 /* shift all left elements one element to the right */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
365 size_t shiftcount = rightstart-start;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
366 void *startptr = array + start*elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
367 void *dest = array + (start+1)*elemsize;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
368 memmove(dest, startptr, shiftcount*elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
369
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
370 /* bring the first value from the right to the left */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
371 memcpy(startptr, value, elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
372
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
373 start++;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
374 mid++;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
375 rightstart++;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
376 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
377 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
378
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
379 /* free the temporary memory */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
380 free(value);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
381 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
382
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
383 static void ucx_mergesort_impl(void *arrdata, size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
384 cmp_func cmpfnc, void *data, size_t l, size_t r) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
385 if (l < r) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
386 size_t m = l + (r - l) / 2;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
387
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
388 ucx_mergesort_impl(arrdata, elemsize, cmpfnc, data, l, m);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
389 ucx_mergesort_impl(arrdata, elemsize, cmpfnc, data, m + 1, r);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
390 ucx_mergesort_merge(arrdata, elemsize, cmpfnc, data, l, m, r);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
391 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
392 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
393
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
394 static void ucx_mergesort(void *arrdata, size_t count, size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
395 cmp_func cmpfnc, void *data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
396
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
397 ucx_mergesort_impl(arrdata, elemsize, cmpfnc, data, 0, count-1);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
398 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
399
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
400 #ifdef USE_UCX_QSORT_R
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
401 struct cmpfnc_swapargs_info {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
402 cmp_func func;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
403 void *data;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
404 };
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
405
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
406 static int cmp_func_swap_args(void *data, const void *x, const void *y) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
407 cmpfnc_swapargs_info* info = data;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
408 return info->func(x, y, info->data);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
409 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
410
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
411 static void ucx_qsort_r(void *array, size_t count, size_t elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
412 cmp_func cmpfnc, void *data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
413 struct cmpfnc_swapargs_info info;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
414 info.func = cmpfnc;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
415 info.data = data;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
416 qsort_r(array, count, elemsize, &info, cmp_func_swap_args);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
417 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
418 #endif /* USE_UCX_QSORT_R */
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
419
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
420 void ucx_array_sort(UcxArray* array, cmp_func cmpfnc, void *data) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
421 ucx_array_sort_impl(array->data, array->size, array->elemsize,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
422 cmpfnc, data);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
423 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
424
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
425 void ucx_array_remove(UcxArray *array, size_t index) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
426 array->size--;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
427 if (index < array->size) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
428 void* dest = ucx_array_at(array, index);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
429 void* src = ucx_array_at(array, index+1);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
430 memmove(dest, src, (array->size - index)*array->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
431 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
432 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
433
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
434 void ucx_array_remove_fast(UcxArray *array, size_t index) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
435 array->size--;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
436 if (index < array->size) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
437 void* dest = ucx_array_at(array, index);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
438 void* src = ucx_array_at(array, array->size);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
439 memcpy(dest, src, array->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
440 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
441 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
442
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
443 int ucx_array_shrink(UcxArray* array) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
444 void* newptr = alrealloc(array->allocator, array->data,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
445 array->size*array->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
446 if (newptr) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
447 array->data = newptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
448 array->capacity = array->size;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
449 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
450 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
451 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
452 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
453 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
454
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
455 int ucx_array_resize(UcxArray* array, size_t capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
456 if (array->capacity >= capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
457 void* newptr = alrealloc(array->allocator, array->data,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
458 capacity*array->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
459 if (newptr) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
460 array->data = newptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
461 array->capacity = capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
462 if (array->size > array->capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
463 array->size = array->capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
464 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
465 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
466 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
467 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
468 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
469 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
470 return ucx_array_reserve(array, capacity);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
471 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
472 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
473
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
474 int ucx_array_reserve(UcxArray* array, size_t capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
475 if (array->capacity > capacity) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
476 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
477 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
478 void* newptr = alrealloc(array->allocator, array->data,
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
479 capacity*array->elemsize);
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
480 if (newptr) {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
481 array->data = newptr;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
482 array->capacity = capacity;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
483 return 0;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
484 } else {
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
485 return 1;
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
486 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
487 }
4784c14aa639 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
488 }

mercurial