| 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 29 matching lines...) Expand all Loading... |
| 40 const unsigned char* us1 = s1; | 40 const unsigned char* us1 = s1; |
| 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, |
| 51 uint64_t len) { |
| 52 if (state->overrun) |
| 53 return NULL; |
| 51 if (len > state->remaining_len) { | 54 if (len > state->remaining_len) { |
| 52 state->remaining_len = -1; | 55 state->overrun = 1; |
| 53 return NULL; | 56 return NULL; |
| 54 } | 57 } |
| 55 Memcpy(dst, state->remaining_buf, len); | 58 Memcpy(dst, state->remaining_buf, len); |
| 56 state->remaining_buf += len; | 59 state->remaining_buf += len; |
| 57 state->remaining_len -= len; | 60 state->remaining_len -= len; |
| 58 return dst; | 61 return dst; |
| 59 } | 62 } |
| 60 | 63 |
| 61 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, int len) { | 64 const void* StatefulMemcpy_r(MemcpyState* state, const void* src, |
| 65 uint64_t len) { |
| 66 if (state->overrun) |
| 67 return NULL; |
| 62 if (len > state->remaining_len) { | 68 if (len > state->remaining_len) { |
| 63 state->remaining_len = -1; | 69 state->overrun = 1; |
| 64 return NULL; | 70 return NULL; |
| 65 } | 71 } |
| 66 Memcpy(state->remaining_buf, src, len); | 72 Memcpy(state->remaining_buf, src, len); |
| 67 state->remaining_buf += len; | 73 state->remaining_buf += len; |
| 68 state->remaining_len -= len; | 74 state->remaining_len -= len; |
| 69 return src; | 75 return src; |
| 70 } | 76 } |
| OLD | NEW |