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

Side by Side Diff: third_party/brotli/dec/streams.c

Issue 1061993007: Update Brotli to revision ec03509 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « third_party/brotli/dec/state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* Copyright 2013 Google Inc. All Rights Reserved. 1 /* Copyright 2013 Google Inc. All Rights Reserved.
2 2
3 Licensed under the Apache License, Version 2.0 (the "License"); 3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License. 4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at 5 You may obtain a copy of the License at
6 6
7 http://www.apache.org/licenses/LICENSE-2.0 7 http://www.apache.org/licenses/LICENSE-2.0
8 8
9 Unless required by applicable law or agreed to in writing, software 9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS, 10 distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 mem_input->buffer = buffer; 44 mem_input->buffer = buffer;
45 mem_input->length = length; 45 mem_input->length = length;
46 mem_input->pos = 0; 46 mem_input->pos = 0;
47 input.cb_ = &BrotliMemInputFunction; 47 input.cb_ = &BrotliMemInputFunction;
48 input.data_ = mem_input; 48 input.data_ = mem_input;
49 return input; 49 return input;
50 } 50 }
51 51
52 int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count) { 52 int BrotliMemOutputFunction(void* data, const uint8_t* buf, size_t count) {
53 BrotliMemOutput* output = (BrotliMemOutput*)data; 53 BrotliMemOutput* output = (BrotliMemOutput*)data;
54 if (output->pos + count > output->length) { 54 size_t limit = output->length - output->pos;
55 return -1; 55 if (count > limit) {
56 count = limit;
56 } 57 }
57 memcpy(output->buffer + output->pos, buf, count); 58 memcpy(output->buffer + output->pos, buf, count);
58 output->pos += count; 59 output->pos += count;
59 return (int)count; 60 return (int)count;
60 } 61 }
61 62
62 BrotliOutput BrotliInitMemOutput(uint8_t* buffer, size_t length, 63 BrotliOutput BrotliInitMemOutput(uint8_t* buffer, size_t length,
63 BrotliMemOutput* mem_output) { 64 BrotliMemOutput* mem_output) {
64 BrotliOutput output; 65 BrotliOutput output;
65 mem_output->buffer = buffer; 66 mem_output->buffer = buffer;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 BrotliOutput out; 122 BrotliOutput out;
122 out.cb_ = BrotliFileOutputFunction; 123 out.cb_ = BrotliFileOutputFunction;
123 out.data_ = f; 124 out.data_ = f;
124 return out; 125 return out;
125 } 126 }
126 127
127 128
128 #if defined(__cplusplus) || defined(c_plusplus) 129 #if defined(__cplusplus) || defined(c_plusplus)
129 } /* extern "C" */ 130 } /* extern "C" */
130 #endif 131 #endif
OLDNEW
« no previous file with comments | « third_party/brotli/dec/state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698