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 |
| 11 #include <stdarg.h> |
11 #include <stdio.h> | 12 #include <stdio.h> |
12 #include <stdlib.h> | 13 #include <stdlib.h> |
13 | 14 |
| 15 void error(const char *format, ...) { |
| 16 va_list ap; |
| 17 va_start(ap, format); |
| 18 fprintf(stderr, "ERROR: "); |
| 19 vfprintf(stderr, format, ap); |
| 20 va_end(ap); |
| 21 exit(1); |
| 22 } |
| 23 |
| 24 void debug(const char *format, ...) { |
| 25 va_list ap; |
| 26 va_start(ap, format); |
| 27 fprintf(stderr, "WARNING: "); |
| 28 vfprintf(stderr, format, ap); |
| 29 va_end(ap); |
| 30 } |
| 31 |
14 void* Malloc(size_t size) { | 32 void* Malloc(size_t size) { |
15 void* p = malloc(size); | 33 void* p = malloc(size); |
16 if (!p) { | 34 if (!p) { |
17 /* Fatal Error. We must abort. */ | 35 /* Fatal Error. We must abort. */ |
18 abort(); | 36 abort(); |
19 } | 37 } |
20 return p; | 38 return p; |
21 } | 39 } |
22 | 40 |
23 void Free(void* ptr) { | 41 void Free(void* ptr) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return NULL; | 85 return NULL; |
68 if (len > state->remaining_len) { | 86 if (len > state->remaining_len) { |
69 state->overrun = 1; | 87 state->overrun = 1; |
70 return NULL; | 88 return NULL; |
71 } | 89 } |
72 Memcpy(state->remaining_buf, src, len); | 90 Memcpy(state->remaining_buf, src, len); |
73 state->remaining_buf += len; | 91 state->remaining_buf += len; |
74 state->remaining_len -= len; | 92 state->remaining_len -= len; |
75 return src; | 93 return src; |
76 } | 94 } |
OLD | NEW |