ucx/utils.h

changeset 244
98dc2d3a9b1d
parent 225
a1a068c2c4ef
child 250
b7d1317b138e
equal deleted inserted replaced
243:2e74828c5e94 244:98dc2d3a9b1d
58 * Copies a string. 58 * Copies a string.
59 * @param s the string to copy 59 * @param s the string to copy
60 * @param data omitted 60 * @param data omitted
61 * @return a pointer to a copy of s1 that can be passed to free(void*) 61 * @return a pointer to a copy of s1 that can be passed to free(void*)
62 */ 62 */
63 void *ucx_strcpy(void *s, void *data); 63 void *ucx_strcpy(const void *s, void *data);
64 64
65 /** 65 /**
66 * Copies a memory area. 66 * Copies a memory area.
67 * @param m a pointer to the memory area 67 * @param m a pointer to the memory area
68 * @param n a pointer to the size_t containing the size of the memory area 68 * @param n a pointer to the size_t containing the size of the memory area
69 * @return a pointer to a copy of the specified memory area that can 69 * @return a pointer to a copy of the specified memory area that can
70 * be passed to free(void*) 70 * be passed to free(void*)
71 */ 71 */
72 void *ucx_memcpy(void *m, void *n); 72 void *ucx_memcpy(const void *m, void *n);
73 73
74 74
75 /** 75 /**
76 * Reads data from a stream and writes it to another stream. 76 * Reads data from a stream and writes it to another stream.
77 * 77 *
142 * @param s1 string one 142 * @param s1 string one
143 * @param s2 string two 143 * @param s2 string two
144 * @param data omitted 144 * @param data omitted
145 * @return the result of strcmp(s1, s2) 145 * @return the result of strcmp(s1, s2)
146 */ 146 */
147 int ucx_strcmp(void *s1, void *s2, void *data); 147 int ucx_strcmp(const void *s1, const void *s2, void *data);
148 148
149 /** 149 /**
150 * Wraps the strncmp function. 150 * Wraps the strncmp function.
151 * @param s1 string one 151 * @param s1 string one
152 * @param s2 string two 152 * @param s2 string two
153 * @param n a pointer to the size_t containing the third strncmp parameter 153 * @param n a pointer to the size_t containing the third strncmp parameter
154 * @return the result of strncmp(s1, s2, *n) 154 * @return the result of strncmp(s1, s2, *n)
155 */ 155 */
156 int ucx_strncmp(void *s1, void *s2, void *n); 156 int ucx_strncmp(const void *s1, const void *s2, void *n);
157 157
158 /** 158 /**
159 * Compares two integers of type int. 159 * Compares two integers of type int.
160 * @param i1 pointer to integer one 160 * @param i1 pointer to integer one
161 * @param i2 pointer to integer two 161 * @param i2 pointer to integer two
162 * @param data omitted 162 * @param data omitted
163 * @return -1, if *i1 is less than *i2, 0 if both are equal, 163 * @return -1, if *i1 is less than *i2, 0 if both are equal,
164 * 1 if *i1 is greater than *i2 164 * 1 if *i1 is greater than *i2
165 */ 165 */
166 int ucx_intcmp(void *i1, void *i2, void *data); 166 int ucx_intcmp(const void *i1, const void *i2, void *data);
167 167
168 /** 168 /**
169 * Compares two real numbers of type float. 169 * Compares two real numbers of type float.
170 * @param f1 pointer to float one 170 * @param f1 pointer to float one
171 * @param f2 pointer to float two 171 * @param f2 pointer to float two
172 * @param data if provided: a pointer to precision (default: 1e-6f) 172 * @param data if provided: a pointer to precision (default: 1e-6f)
173 * @return -1, if *f1 is less than *f2, 0 if both are equal, 173 * @return -1, if *f1 is less than *f2, 0 if both are equal,
174 * 1 if *f1 is greater than *f2 174 * 1 if *f1 is greater than *f2
175 */ 175 */
176 176
177 int ucx_floatcmp(void *f1, void *f2, void *data); 177 int ucx_floatcmp(const void *f1, const void *f2, void *data);
178 178
179 /** 179 /**
180 * Compares two real numbers of type double. 180 * Compares two real numbers of type double.
181 * @param d1 pointer to double one 181 * @param d1 pointer to double one
182 * @param d2 pointer to double two 182 * @param d2 pointer to double two
183 * @param data if provided: a pointer to precision (default: 1e-14) 183 * @param data if provided: a pointer to precision (default: 1e-14)
184 * @return -1, if *d1 is less than *d2, 0 if both are equal, 184 * @return -1, if *d1 is less than *d2, 0 if both are equal,
185 * 1 if *d1 is greater than *d2 185 * 1 if *d1 is greater than *d2
186 */ 186 */
187 int ucx_doublecmp(void *d1, void *d2, void *data); 187 int ucx_doublecmp(const void *d1, const void *d2, void *data);
188 188
189 /** 189 /**
190 * Compares two pointers. 190 * Compares two pointers.
191 * @param ptr1 pointer one 191 * @param ptr1 pointer one
192 * @param ptr2 pointer two 192 * @param ptr2 pointer two
193 * @param data omitted 193 * @param data omitted
194 * @return -1 if ptr1 is less than ptr2, 0 if both are equal, 194 * @return -1 if ptr1 is less than ptr2, 0 if both are equal,
195 * 1 if ptr1 is greater than ptr2 195 * 1 if ptr1 is greater than ptr2
196 */ 196 */
197 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data); 197 int ucx_ptrcmp(const void *ptr1, const void *ptr2, void *data);
198 198
199 /** 199 /**
200 * Compares two memory areas. 200 * Compares two memory areas.
201 * @param ptr1 pointer one 201 * @param ptr1 pointer one
202 * @param ptr2 pointer two 202 * @param ptr2 pointer two
203 * @param n a pointer to the size_t containing the third parameter for memcmp 203 * @param n a pointer to the size_t containing the third parameter for memcmp
204 * @return the result of memcmp(ptr1, ptr2, *n) 204 * @return the result of memcmp(ptr1, ptr2, *n)
205 */ 205 */
206 int ucx_memcmp(void *ptr1, void *ptr2, void *n); 206 int ucx_memcmp(const void *ptr1, const void *ptr2, void *n);
207 207
208 /** 208 /**
209 * A <code>printf()</code> like function which writes the output to a stream by 209 * A <code>printf()</code> like function which writes the output to a stream by
210 * using a write_func(). 210 * using a write_func().
211 * @param stream the stream the data is written to 211 * @param stream the stream the data is written to

mercurial