| 31 |
31 |
| 32 The `cx_stream_copy()` function always uses internal stack memory as a temporary buffer for the read bytes. |
32 The `cx_stream_copy()` function always uses internal stack memory as a temporary buffer for the read bytes. |
| 33 The `cx_stream_bcopy()` function uses either a pre-initialized buffer `buf` of length `bufsize` |
33 The `cx_stream_bcopy()` function uses either a pre-initialized buffer `buf` of length `bufsize` |
| 34 or, if `buf` is `NULL`, an internal heap-allocated buffer. |
34 or, if `buf` is `NULL`, an internal heap-allocated buffer. |
| 35 |
35 |
| 36 The `cx_stream_ncopy()` function behaves like `cx_stream_copy()` except, that it reads at most `n` bytes |
36 The `cx_stream_ncopy()` function behaves like `cx_stream_copy()` except that it reads at most `n` bytes |
| 37 (and the same is true for `cx_stream_bncopy()` and `cx_stream_bcopy()`). |
37 (and the same is true for `cx_stream_bncopy()` and `cx_stream_bcopy()`). |
| 38 |
38 |
| 39 |
39 |
| 40 > When you are reading from a stream where you cannot track the position, there is the possibility that |
40 > When you are reading from a stream where you cannot track the position, there is the possibility that |
| 41 > data gets lost when the destination does not accept all the bytes read from the source. |
41 > data gets lost when the destination does not accept all the bytes read from the source. |
| 52 > configured via the `CX_STREAM_BCOPY_BUF_SIZE` macro. |
52 > configured via the `CX_STREAM_BCOPY_BUF_SIZE` macro. |
| 53 > Refer to the [build instructions](install.md#compile-time-options) for the details. |
53 > Refer to the [build instructions](install.md#compile-time-options) for the details. |
| 54 |
54 |
| 55 ## Example |
55 ## Example |
| 56 |
56 |
| 57 The following example shows, how to read the contents of a file into a buffer: |
57 The following example shows how to read the contents of a file into a buffer: |
| 58 ```c |
58 ```c |
| 59 FILE *inputfile = fopen(infilename, "r"); |
59 FILE *inputfile = fopen(infilename, "r"); |
| 60 if (inputfile) { |
60 if (inputfile) { |
| 61 CxBuffer fbuf; |
61 CxBuffer fbuf; |
| 62 cxBufferInit(&fbuf, NULL, NULL, 4096, CX_BUFFER_AUTO_EXTEND); |
62 cxBufferInit(&fbuf, NULL, NULL, 4096, CX_BUFFER_AUTO_EXTEND); |