OLD | NEW |
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 * Stub implementations of utility functions which call their linux-specific | 5 * Stub implementations of utility functions which call their linux-specific |
6 * equivalents. | 6 * equivalents. |
7 */ | 7 */ |
8 | 8 |
9 #include "utility.h" | 9 #include "utility.h" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 const unsigned char* us2 = s2; | 41 const unsigned char* us2 = s2; |
42 while (n--) { | 42 while (n--) { |
43 if (*us1++ != *us2++) | 43 if (*us1++ != *us2++) |
44 match = 1; | 44 match = 1; |
45 } | 45 } |
46 | 46 |
47 return match; | 47 return match; |
48 } | 48 } |
49 | 49 |
50 void* StatefulMemcpy(MemcpyState* state, void* dst, int len) { | 50 void* StatefulMemcpy(MemcpyState* state, void* dst, int len) { |
51 void* saved_ptr; | |
52 if (len > state->remaining_len) { | 51 if (len > state->remaining_len) { |
53 state->remaining_len = -1; | 52 state->remaining_len = -1; |
54 return NULL; | 53 return NULL; |
55 } | 54 } |
56 saved_ptr = state->remaining_buf; | 55 Memcpy(dst, state->remaining_buf, len); |
57 Memcpy(dst, saved_ptr, len); | |
58 state->remaining_buf += len; | 56 state->remaining_buf += len; |
59 state->remaining_len -= len; | 57 state->remaining_len -= len; |
60 return dst; | 58 return dst; |
61 } | 59 } |
| 60 |
| 61 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, int len) { |
| 62 if (len > state->remaining_len) { |
| 63 state->remaining_len = -1; |
| 64 return NULL; |
| 65 } |
| 66 Memcpy(state->remaining_buf, src, len); |
| 67 state->remaining_buf += len; |
| 68 state->remaining_len -= len; |
| 69 return src; |
| 70 } |
OLD | NEW |