OLD | NEW |
(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 "utility.h" |
| 10 |
| 11 #include <stdio.h> |
| 12 #include <stdlib.h> |
| 13 #include <string.h> |
| 14 |
| 15 void* Malloc(size_t size) { |
| 16 void* p = malloc(size); |
| 17 if (!p) { |
| 18 /* Fatal Error. We must abort. */ |
| 19 abort(); |
| 20 } |
| 21 return p; |
| 22 } |
| 23 |
| 24 void Free(void* ptr) { |
| 25 free(ptr); |
| 26 } |
| 27 |
| 28 void* Memcpy(void* dest, const void* src, size_t n) { |
| 29 return memcpy(dest, src, n); |
| 30 } |
| 31 |
| 32 int SafeMemcmp(const void* s1, const void* s2, size_t n) { |
| 33 int match = 1; |
| 34 const unsigned char* us1 = s1; |
| 35 const unsigned char* us2 = s2; |
| 36 while (n--) { |
| 37 if (*us1++ != *us2++) |
| 38 match = 0; |
| 39 else |
| 40 match = 1; |
| 41 } |
| 42 |
| 43 return match; |
| 44 } |
OLD | NEW |