docs/src/features.md

changeset 1112
22dc2163fffd
parent 998
bb196054f3fd
equal deleted inserted replaced
1111:78eeeb950883 1112:22dc2163fffd
125 125
126 // create a buffer using the memory pool for destruction 126 // create a buffer using the memory pool for destruction
127 CxBuffer *content = cxBufferCreate(NULL, 256, pool->allocator, CX_BUFFER_AUTO_EXTEND); 127 CxBuffer *content = cxBufferCreate(NULL, 256, pool->allocator, CX_BUFFER_AUTO_EXTEND);
128 128
129 // read the file into the buffer and turn it into a string 129 // read the file into the buffer and turn it into a string
130 cx_stream_copy(f, content, (cx_read_func) fread, (cx_write_func) cxBufferWrite); 130 cx_stream_copy(f, content, (cx_read_func) fread, cxBufferWriteFunc);
131 fclose(f); 131 fclose(f);
132 cxstring contentstr = cx_strn(content->space, content->size); 132 cxstring contentstr = cx_strn(content->space, content->size);
133 133
134 // split the string into lines - use the mempool for allocating the target array 134 // split the string into lines - use the mempool for allocating the target array
135 cxstring* lines; 135 cxstring* lines;
361 if (inputfile) { 361 if (inputfile) {
362 CxBuffer fbuf; 362 CxBuffer fbuf;
363 cxBufferInit(&fbuf, NULL, 4096, NULL, CX_BUFFER_AUTO_EXTEND); 363 cxBufferInit(&fbuf, NULL, 4096, NULL, CX_BUFFER_AUTO_EXTEND);
364 cx_stream_copy(inputfile, &fbuf, 364 cx_stream_copy(inputfile, &fbuf,
365 (cx_read_func) fread, 365 (cx_read_func) fread,
366 (cx_write_func) cxBufferWrite); 366 cxBufferWriteFunc);
367 fclose(inputfile); 367 fclose(inputfile);
368 368
369 // ... do something meaningful with the contents ... 369 // ... do something meaningful with the contents ...
370 370
371 cxBufferDestroy(&fbuf); 371 cxBufferDestroy(&fbuf);

mercurial