• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AOM_MEM_AOM_MEM_H_
13 #define AOM_AOM_MEM_AOM_MEM_H_
14 
15 #include "aom/aom_integer.h"
16 #include "config/aom_config.h"
17 
18 #if defined(__uClinux__)
19 #include <lddk.h>
20 #endif
21 
22 #if defined(__cplusplus)
23 extern "C" {
24 #endif
25 
26 #ifndef AOM_MAX_ALLOCABLE_MEMORY
27 #if SIZE_MAX > (1ULL << 32)
28 #define AOM_MAX_ALLOCABLE_MEMORY 8589934592  // 8 GB
29 #else
30 // For 32-bit targets keep this below INT_MAX to avoid valgrind warnings.
31 #define AOM_MAX_ALLOCABLE_MEMORY ((1ULL << 31) - (1 << 16))
32 #endif
33 #endif
34 
35 void *aom_memalign(size_t align, size_t size);
36 void *aom_malloc(size_t size);
37 void *aom_calloc(size_t num, size_t size);
38 void aom_free(void *memblk);
39 void *aom_memset16(void *dest, int val, size_t length);
40 
41 #include <string.h>
42 
43 #ifdef AOM_MEM_PLTFRM
44 #include AOM_MEM_PLTFRM
45 #endif
46 
47 #if CONFIG_DEBUG
48 #define AOM_CHECK_MEM_ERROR(error_info, lval, expr)                         \
49   do {                                                                      \
50     lval = (expr);                                                          \
51     if (!lval)                                                              \
52       aom_internal_error(error_info, AOM_CODEC_MEM_ERROR,                   \
53                          "Failed to allocate " #lval " at %s:%d", __FILE__, \
54                          __LINE__);                                         \
55   } while (0)
56 #else
57 #define AOM_CHECK_MEM_ERROR(error_info, lval, expr)       \
58   do {                                                    \
59     lval = (expr);                                        \
60     if (!lval)                                            \
61       aom_internal_error(error_info, AOM_CODEC_MEM_ERROR, \
62                          "Failed to allocate " #lval);    \
63   } while (0)
64 #endif
65 
66 #if defined(__cplusplus)
67 }
68 #endif
69 
70 #endif  // AOM_AOM_MEM_AOM_MEM_H_
71