ucx/properties.c

changeset 888
af685cc9d623
parent 854
1c8401ece69e
equal deleted inserted replaced
877:b60487c3ec36 888:af685cc9d623
49 void cxPropertiesDestroy(CxProperties *prop) { 49 void cxPropertiesDestroy(CxProperties *prop) {
50 cxBufferDestroy(&prop->input); 50 cxBufferDestroy(&prop->input);
51 cxBufferDestroy(&prop->buffer); 51 cxBufferDestroy(&prop->buffer);
52 } 52 }
53 53
54 void cxPropertiesReset(CxProperties *prop) {
55 CxPropertiesConfig config = prop->config;
56 cxPropertiesDestroy(prop);
57 cxPropertiesInit(prop, config);
58 }
59
54 int cxPropertiesFilln( 60 int cxPropertiesFilln(
55 CxProperties *prop, 61 CxProperties *prop,
56 const char *buf, 62 const char *buf,
57 size_t len 63 size_t len
58 ) { 64 ) {
242 cxstring value 248 cxstring value
243 ) { 249 ) {
244 CxMap *map = sink->sink; 250 CxMap *map = sink->sink;
245 CxAllocator *alloc = sink->data; 251 CxAllocator *alloc = sink->data;
246 cxmutstr v = cx_strdup_a(alloc, value); 252 cxmutstr v = cx_strdup_a(alloc, value);
247 int r = cx_map_put_cxstr(map, key, v.ptr); 253 int r = cxMapPut(map, key, v.ptr);
248 if (r != 0) cx_strfree_a(alloc, &v); 254 if (r != 0) cx_strfree_a(alloc, &v);
249 return r; 255 return r;
250 } 256 }
251 257
252 CxPropertiesSink cxPropertiesMapSink(CxMap *map) { 258 CxPropertiesSink cxPropertiesMapSink(CxMap *map) {
285 291
286 static int cx_properties_read_init_file( 292 static int cx_properties_read_init_file(
287 cx_attr_unused CxProperties *prop, 293 cx_attr_unused CxProperties *prop,
288 CxPropertiesSource *src 294 CxPropertiesSource *src
289 ) { 295 ) {
290 src->data_ptr = malloc(src->data_size); 296 src->data_ptr = cxMallocDefault(src->data_size);
291 if (src->data_ptr == NULL) return 1; 297 if (src->data_ptr == NULL) return 1;
292 return 0; 298 return 0;
293 } 299 }
294 300
295 static void cx_properties_read_clean_file( 301 static void cx_properties_read_clean_file(
296 cx_attr_unused CxProperties *prop, 302 cx_attr_unused CxProperties *prop,
297 CxPropertiesSource *src 303 CxPropertiesSource *src
298 ) { 304 ) {
299 free(src->data_ptr); 305 cxFreeDefault(src->data_ptr);
300 } 306 }
301 307
302 CxPropertiesSource cxPropertiesStringSource(cxstring str) { 308 CxPropertiesSource cxPropertiesStringSource(cxstring str) {
303 CxPropertiesSource src; 309 CxPropertiesSource src;
304 src.src = (void*) str.ptr; 310 src.src = (void*) str.ptr;

mercurial