This source file includes following definitions.
- malloc
 
- free
 
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 #ifndef DECOMPR_MM_H
  12 #define DECOMPR_MM_H
  13 
  14 #ifdef STATIC
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  23 
  24 #ifndef STATIC_RW_DATA
  25 #define STATIC_RW_DATA static
  26 #endif
  27 
  28 
  29 
  30 
  31 STATIC_RW_DATA unsigned long malloc_ptr;
  32 STATIC_RW_DATA int malloc_count;
  33 
  34 static void *malloc(int size)
  35 {
  36         void *p;
  37 
  38         if (size < 0)
  39                 return NULL;
  40         if (!malloc_ptr)
  41                 malloc_ptr = free_mem_ptr;
  42 
  43         malloc_ptr = (malloc_ptr + 3) & ~3;     
  44 
  45         p = (void *)malloc_ptr;
  46         malloc_ptr += size;
  47 
  48         if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
  49                 return NULL;
  50 
  51         malloc_count++;
  52         return p;
  53 }
  54 
  55 static void free(void *where)
  56 {
  57         malloc_count--;
  58         if (!malloc_count)
  59                 malloc_ptr = free_mem_ptr;
  60 }
  61 
  62 #define large_malloc(a) malloc(a)
  63 #define large_free(a) free(a)
  64 
  65 #define INIT
  66 
  67 #else 
  68 
  69 
  70 
  71 #include <linux/kernel.h>
  72 #include <linux/fs.h>
  73 #include <linux/string.h>
  74 #include <linux/slab.h>
  75 #include <linux/vmalloc.h>
  76 
  77 
  78 
  79 
  80 
  81 #define malloc(a) kmalloc(a, GFP_KERNEL)
  82 #define free(a) kfree(a)
  83 
  84 #define large_malloc(a) vmalloc(a)
  85 #define large_free(a) vfree(a)
  86 
  87 #define INIT __init
  88 #define STATIC
  89 
  90 #include <linux/init.h>
  91 
  92 #endif 
  93 
  94 #endif