0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef DECOMPR_MM_H
0012 #define DECOMPR_MM_H
0013
0014 #ifdef STATIC
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #ifndef STATIC_RW_DATA
0025 #define STATIC_RW_DATA static
0026 #endif
0027
0028
0029
0030
0031
0032 #ifndef MALLOC_VISIBLE
0033 #define MALLOC_VISIBLE static
0034 #endif
0035
0036
0037
0038
0039 STATIC_RW_DATA unsigned long malloc_ptr;
0040 STATIC_RW_DATA int malloc_count;
0041
0042 MALLOC_VISIBLE void *malloc(int size)
0043 {
0044 void *p;
0045
0046 if (size < 0)
0047 return NULL;
0048 if (!malloc_ptr)
0049 malloc_ptr = free_mem_ptr;
0050
0051 malloc_ptr = (malloc_ptr + 3) & ~3;
0052
0053 p = (void *)malloc_ptr;
0054 malloc_ptr += size;
0055
0056 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
0057 return NULL;
0058
0059 malloc_count++;
0060 return p;
0061 }
0062
0063 MALLOC_VISIBLE void free(void *where)
0064 {
0065 malloc_count--;
0066 if (!malloc_count)
0067 malloc_ptr = free_mem_ptr;
0068 }
0069
0070 #define large_malloc(a) malloc(a)
0071 #define large_free(a) free(a)
0072
0073 #define INIT
0074
0075 #else
0076
0077
0078
0079 #include <linux/kernel.h>
0080 #include <linux/fs.h>
0081 #include <linux/string.h>
0082 #include <linux/slab.h>
0083 #include <linux/vmalloc.h>
0084
0085
0086
0087
0088
0089 #define malloc(a) kmalloc(a, GFP_KERNEL)
0090 #define free(a) kfree(a)
0091
0092 #define large_malloc(a) vmalloc(a)
0093 #define large_free(a) vfree(a)
0094
0095 #define INIT __init
0096 #define STATIC
0097
0098 #include <linux/init.h>
0099
0100 #endif
0101
0102 #endif