src/c2html.c

changeset 70
60cecca5e484
parent 67
5da2cb5aea6b
child 71
d5af9261231d
equal deleted inserted replaced
69:ff56b28e2cdd 70:60cecca5e484
29 29
30 #include "c2html.h" 30 #include "c2html.h"
31 31
32 #include <cx/array_list.h> 32 #include <cx/array_list.h>
33 #include <cx/printf.h> 33 #include <cx/printf.h>
34 #include <string.h>
34 35
35 size_t c2html_format( 36 size_t c2html_format(
36 CxList const *lines, 37 CxList const *lines,
37 void *outbuf, 38 void *outbuf,
38 cx_write_func wfnc, 39 cx_write_func wfnc,
90 cxBufferDestroy(&out_line); 91 cxBufferDestroy(&out_line);
91 92
92 return written; 93 return written;
93 } 94 }
94 95
95 size_t c2html_bformat( 96 size_t c2html_textformat(
96 char const *inputbuffer, 97 char const *inputbuffer,
97 size_t inputbuflen,
98 void *outbuf, 98 void *outbuf,
99 cx_write_func wfnc, 99 cx_write_func wfnc,
100 c2html_highlighter_func highlighter, 100 c2html_highlighter_func highlighter,
101 int showln 101 int showln
102 ) { 102 ) {
103 /* a rough estimate for the number of lines */ 103 /* a rough estimate for the number of lines */
104 size_t inputbuflen = strlen(inputbuffer);
104 size_t est_cap = 16 + inputbuflen / 40; 105 size_t est_cap = 16 + inputbuflen / 40;
105 106
106 /* create the line pointer array */ 107 /* create the line pointer array */
107 CxList *lines = cxArrayListCreateSimple(CX_STORE_POINTERS, est_cap); 108 CxList *lines = cxArrayListCreateSimple(CX_STORE_POINTERS, est_cap);
108 cxListAdd(lines, inputbuffer); 109 cxListAdd(lines, inputbuffer);

mercurial