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

Side by Side Diff: src/platform/vboot_reference/vboot_firmware/lib/stateful_util.c

Issue 2255006: StatefulMem* functions should be library functions. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
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
OLDNEW
(Empty)
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
3 * found in the LICENSE file.
4 *
5 * Stub implementations of utility functions which call their linux-specific
6 * equivalents.
7 */
8
9 #include "stateful_util.h"
10
11 #include <stdarg.h>
12 #include <stdio.h>
13 #include <stdlib.h>
14
15 void* StatefulMemcpy(MemcpyState* state, void* dst,
16 uint64_t len) {
17 if (state->overrun)
18 return NULL;
19 if (len > state->remaining_len) {
20 state->overrun = 1;
21 return NULL;
22 }
23 Memcpy(dst, state->remaining_buf, len);
24 state->remaining_buf += len;
25 state->remaining_len -= len;
26 return dst;
27 }
28
29 const void* StatefulMemcpy_r(MemcpyState* state, const void* src,
30 uint64_t len) {
31 if (state->overrun)
32 return NULL;
33 if (len > state->remaining_len) {
34 state->overrun = 1;
35 return NULL;
36 }
37 Memcpy(state->remaining_buf, src, len);
38 state->remaining_buf += len;
39 state->remaining_len -= len;
40 return src;
41 }
42
43 const void* StatefulMemset_r(MemcpyState* state, const uint8_t val,
44 uint64_t len) {
45 if (state->overrun)
46 return NULL;
47 if (len > state->remaining_len) {
48 state->overrun = 1;
49 return NULL;
50 }
51 Memset(state->remaining_buf, val, len);
52 state->remaining_buf += len;
53 state->remaining_len -= len;
54 return state; // have to return something non-NULL
55 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698