Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: xz/src/liblzma/common/filter_buffer_encoder.c

Issue 2869016: Add an unpatched version of xz, XZ Utils, to /trunk/deps/third_party (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « xz/src/liblzma/common/filter_buffer_decoder.c ('k') | xz/src/liblzma/common/filter_common.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file filter_buffer_encoder.c
4 /// \brief Single-call raw encoding
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
11 ///////////////////////////////////////////////////////////////////////////////
12
13 #include "filter_encoder.h"
14
15
16 extern LZMA_API(lzma_ret)
17 lzma_raw_buffer_encode(const lzma_filter *filters, lzma_allocator *allocator,
18 const uint8_t *in, size_t in_size, uint8_t *out,
19 size_t *out_pos, size_t out_size)
20 {
21 // Validate what isn't validated later in filter_common.c.
22 if ((in == NULL && in_size != 0) || out == NULL
23 || out_pos == NULL || *out_pos > out_size)
24 return LZMA_PROG_ERROR;
25
26 // Initialize the encoder
27 lzma_next_coder next = LZMA_NEXT_CODER_INIT;
28 return_if_error(lzma_raw_encoder_init(&next, allocator, filters));
29
30 // Store the output position so that we can restore it if
31 // something goes wrong.
32 const size_t out_start = *out_pos;
33
34 // Do the actual encoding and free coder's memory.
35 size_t in_pos = 0;
36 lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size,
37 out, out_pos, out_size, LZMA_FINISH);
38 lzma_next_end(&next, allocator);
39
40 if (ret == LZMA_STREAM_END) {
41 ret = LZMA_OK;
42 } else {
43 if (ret == LZMA_OK) {
44 // Output buffer was too small.
45 assert(*out_pos == out_size);
46 ret = LZMA_BUF_ERROR;
47 }
48
49 // Restore the output position.
50 *out_pos = out_start;
51 }
52
53 return ret;
54 }
OLDNEW
« no previous file with comments | « xz/src/liblzma/common/filter_buffer_decoder.c ('k') | xz/src/liblzma/common/filter_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698