blob: 14a5910fbad8911e2a375e07fd6925a049983159 [file] [log] [blame]
Gaurav Shah322536d2010-01-28 15:01:23 -08001/* 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
15void* 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
24void Free(void* ptr) {
25 free(ptr);
26}
27
28void* Memcpy(void* dest, const void* src, size_t n) {
29 return memcpy(dest, src, n);
30}
31
32int 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}