]> Git Repo - J-u-boot.git/blobdiff - include/malloc.h
Merge patch series "PLL Sequencing update"
[J-u-boot.git] / include / malloc.h
index 1fbaf3755c7aa2b1f4bd1b3804ae06d3d3ff047a..9e0be482416efc970dd52874a9de114493325f18 100644 (file)
      quickly avoid procedure declaration conflicts and linker symbol
      conflicts with existing memory allocation routines.
 
-
 */
 
 \f
@@ -256,12 +255,10 @@ extern "C" {
 #include <stdio.h>     /* needed for malloc_stats */
 #endif
 
-
 /*
   Compile-time options
 */
 
-
 /*
     Debugging:
 
@@ -306,10 +303,8 @@ extern "C" {
   returns a unique pointer for malloc(0), so does realloc(p, 0).
 */
 
-
 /*   #define REALLOC_ZERO_BYTES_FREES */
 
-
 /*
   WIN32 causes an emulation of sbrk to be compiled in
   mmap-based options are not currently supported in WIN32.
@@ -335,7 +330,6 @@ extern "C" {
 #include <windows.h>
 #endif
 
-
 /*
   HAVE_MEMCPY should be defined if you are not otherwise using
   ANSI STD C, but still have memcpy and memset in your C library
@@ -460,7 +454,6 @@ do {                                                                          \
 
 #endif
 
-
 /*
   Define HAVE_MMAP to optionally make malloc() use mmap() to
   allocate very large blocks.  These will be returned to the
@@ -563,7 +556,6 @@ do {                                                                          \
 #  endif
 #endif
 
-
 /*
 
   This version of malloc supports the standard SVID/XPG mallinfo
@@ -626,7 +618,6 @@ struct mallinfo {
 #define M_MMAP_THRESHOLD    -3
 #define M_MMAP_MAX          -4
 
-
 #ifndef DEFAULT_TRIM_THRESHOLD
 #define DEFAULT_TRIM_THRESHOLD (128 * 1024)
 #endif
@@ -677,10 +668,8 @@ struct mallinfo {
       It must be greater than page size to have any useful effect.  To
       disable trimming completely, you can set to (unsigned long)(-1);
 
-
 */
 
-
 #ifndef DEFAULT_TOP_PAD
 #define DEFAULT_TOP_PAD        (0)
 #endif
@@ -713,7 +702,6 @@ struct mallinfo {
 
 */
 
-
 #ifndef DEFAULT_MMAP_THRESHOLD
 #define DEFAULT_MMAP_THRESHOLD (128 * 1024)
 #endif
@@ -753,10 +741,8 @@ struct mallinfo {
       All together, these considerations should lead you to use mmap
       only for relatively large requests.
 
-
 */
 
-
 #ifndef DEFAULT_MMAP_MAX
 #ifdef HAVE_MMAP
 #define DEFAULT_MMAP_MAX       (64)
@@ -784,7 +770,6 @@ struct mallinfo {
       in mallopt will fail.
 */
 
-
 /*
     USE_DL_PREFIX will prefix all public routines with the string 'dl'.
       Useful to quickly avoid procedure declaration conflicts and linker
@@ -815,7 +800,6 @@ struct mallinfo {
 
 */
 
-
 #ifdef INTERNAL_LINUX_C_LIB
 
 #if __STD_C
@@ -883,11 +867,27 @@ extern Void_t*     sbrk();
 
 void malloc_simple_info(void);
 
+/**
+ * malloc_enable_testing() - Put malloc() into test mode
+ *
+ * This only works if UNIT_TESTING is enabled
+ *
+ * @max_allocs: return -ENOMEM after max_allocs calls to malloc()
+ */
+void malloc_enable_testing(int max_allocs);
+
+/** malloc_disable_testing() - Put malloc() into normal mode */
+void malloc_disable_testing(void);
+
 #if CONFIG_IS_ENABLED(SYS_MALLOC_SIMPLE)
 #define malloc malloc_simple
 #define realloc realloc_simple
 #define memalign memalign_simple
+#if IS_ENABLED(CONFIG_VALGRIND)
+#define free free_simple
+#else
 static inline void free(void *ptr) {}
+#endif
 void *calloc(size_t nmemb, size_t size);
 void *realloc_simple(void *ptr, size_t size);
 #else
@@ -981,6 +981,14 @@ extern ulong mem_malloc_start;
 extern ulong mem_malloc_end;
 extern ulong mem_malloc_brk;
 
+/**
+ * mem_malloc_init() - Set up the malloc() pool
+ *
+ * Sets the region of memory to be used for all future calls to malloc(), etc.
+ *
+ * @start: Start address
+ * @size: Size in bytes
+ */
 void mem_malloc_init(ulong start, ulong size);
 
 #ifdef __cplusplus
This page took 0.029595 seconds and 4 git commands to generate.