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

Side by Side Diff: src/platform/vboot_reference/include/utility.h

Issue 661353: Vboot Reference: Refactor Code. (Closed)
Patch Set: Review Fixes. Created 10 years, 9 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
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 /* Helper functions/wrappers for memory allocations, manipulation and 6 /* Helper functions/wrappers for memory allocations, manipulation and
7 * comparison. 7 * comparison.
8 */ 8 */
9 9
10 #ifndef VBOOT_REFERENCE_UTILITY_H_ 10 #ifndef VBOOT_REFERENCE_UTILITY_H_
(...skipping 23 matching lines...) Expand all
34 int SafeMemcmp(const void* s1, const void* s2, size_t n); 34 int SafeMemcmp(const void* s1, const void* s2, size_t n);
35 35
36 /* Track remaining data to be read in a buffer. */ 36 /* Track remaining data to be read in a buffer. */
37 typedef struct MemcpyState { 37 typedef struct MemcpyState {
38 void* remaining_buf; 38 void* remaining_buf;
39 int remaining_len; 39 int remaining_len;
40 } MemcpyState; 40 } MemcpyState;
41 41
42 /* Copy [len] bytes into [dst] only if there's enough data to read according 42 /* Copy [len] bytes into [dst] only if there's enough data to read according
43 * to [state]. 43 * to [state].
44 * On success, return [dst] and update [state].. 44 * On success, return [dst] and update [state].
45 * On failure, return NULL, set remaining len in state to -1. 45 * On failure, return NULL, set remaining len in state to -1.
46 * 46 *
47 * Useful for iterating through a binary blob to populate a struct. After the 47 * Useful for iterating through a binary blob to populate a struct. After the
48 * first failure (buffer overrun), successive calls will always fail. 48 * first failure (buffer overrun), successive calls will always fail.
49 */ 49 */
50 void* StatefulMemcpy(MemcpyState* state, void* dst, int len); 50 void* StatefulMemcpy(MemcpyState* state, void* dst, int len);
51 51
52 /* Like StatefulMemcpy() but copies in the opposite direction, populating
53 * data from [src] into the buffer encapsulated in state [state].
54 * On success, return [src] and update [state].
55 * On failure, return NULL, set remaining_len in state to -1.
56 *
57 * Useful for iterating through a structure to populate a binary blob. After the
58 * first failure (buffer overrun), successive calls will always fail.
59 */
60 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, int len);
52 61
53 #endif /* VBOOT_REFERENCE_UTILITY_H_ */ 62 #endif /* VBOOT_REFERENCE_UTILITY_H_ */
OLDNEW
« no previous file with comments | « src/platform/vboot_reference/include/signature_digest.h ('k') | src/platform/vboot_reference/tests/Makefile » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698