Browse code

mem: define the MAX_MALLOC_SIZE constant and use it in place of INT_MAX

This makes re-dimensionating the constant simpler, since now it is
defined only in one place.

Stefano Sabatini authored on 2011/05/19 06:59:38
Showing 1 changed files
... ...
@@ -65,6 +65,8 @@ void  free(void *ptr);
65 65
    memory allocator. You do not need to suppress this file because the
66 66
    linker will do it automatically. */
67 67
 
68
+#define MAX_MALLOC_SIZE INT_MAX
69
+
68 70
 void *av_malloc(size_t size)
69 71
 {
70 72
     void *ptr = NULL;
... ...
@@ -73,7 +75,7 @@ void *av_malloc(size_t size)
73 73
 #endif
74 74
 
75 75
     /* let's disallow possible ambiguous cases */
76
-    if(size > (INT_MAX-32) )
76
+    if (size > (MAX_MALLOC_SIZE-32))
77 77
         return NULL;
78 78
 
79 79
 #if CONFIG_MEMALIGN_HACK
... ...
@@ -127,7 +129,7 @@ void *av_realloc(void *ptr, size_t size)
127 127
 #endif
128 128
 
129 129
     /* let's disallow possible ambiguous cases */
130
-    if(size > (INT_MAX-16) )
130
+    if (size > (MAX_MALLOC_SIZE-16))
131 131
         return NULL;
132 132
 
133 133
 #if CONFIG_MEMALIGN_HACK