| 1415 CxBuffer buffer; |
1415 CxBuffer buffer; |
| 1416 if (cxBufferInit(&buffer, NULL, 128, allocator, |
1416 if (cxBufferInit(&buffer, NULL, 128, allocator, |
| 1417 CX_BUFFER_AUTO_EXTEND | CX_BUFFER_DO_NOT_FREE)) { |
1417 CX_BUFFER_AUTO_EXTEND | CX_BUFFER_DO_NOT_FREE)) { |
| 1418 return (cxmutstr){NULL, 0}; |
1418 return (cxmutstr){NULL, 0}; |
| 1419 } |
1419 } |
| 1420 if (cx_json_write_rec(&buffer, value, cxBufferWriteFunc, writer, 0)) { |
1420 if (cx_json_write_rec(&buffer, value, cxBufferWriteFunc, writer, 0) |
| |
1421 || cxBufferTerminate(&buffer)) { |
| 1421 // LCOV_EXCL_START |
1422 // LCOV_EXCL_START |
| 1422 buffer.flags &= ~CX_BUFFER_DO_NOT_FREE; |
1423 buffer.flags &= ~CX_BUFFER_DO_NOT_FREE; |
| 1423 cxBufferDestroy(&buffer); |
1424 cxBufferDestroy(&buffer); |
| 1424 return (cxmutstr){NULL, 0}; |
1425 return (cxmutstr){NULL, 0}; |
| 1425 // LCOV_EXCL_STOP |
1426 // LCOV_EXCL_STOP |
| 1426 } else { |
1427 } else { |
| 1427 cxBufferTerminate(&buffer); |
|
| 1428 cxmutstr str = cx_mutstrn(buffer.space, buffer.size); |
1428 cxmutstr str = cx_mutstrn(buffer.space, buffer.size); |
| 1429 cxBufferDestroy(&buffer); |
1429 cxBufferDestroy(&buffer); |
| 1430 return str; |
1430 return str; |
| 1431 } |
1431 } |
| 1432 |
1432 |