195 |
{ |
{ |
196 |
pupa_mm_region_t r; |
pupa_mm_region_t r; |
197 |
pupa_size_t n = ((size + PUPA_MM_ALIGN - 1) >> PUPA_MM_ALIGN_LOG2) + 1; |
pupa_size_t n = ((size + PUPA_MM_ALIGN - 1) >> PUPA_MM_ALIGN_LOG2) + 1; |
198 |
int first = 1; |
int count = 0; |
199 |
|
|
200 |
align = (align >> PUPA_MM_ALIGN_LOG2); |
align = (align >> PUPA_MM_ALIGN_LOG2); |
201 |
if (align == 0) |
if (align == 0) |
212 |
return p; |
return p; |
213 |
} |
} |
214 |
|
|
215 |
/* If failed, invalidate disk caches to increase free memory. */ |
/* If failed, increase free memory somehow. */ |
216 |
if (first) |
switch (count) |
217 |
{ |
{ |
218 |
|
case 0: |
219 |
|
/* Invalidate disk caches. */ |
220 |
pupa_disk_cache_invalidate_all (); |
pupa_disk_cache_invalidate_all (); |
221 |
first = 0; |
count++; |
222 |
|
goto again; |
223 |
|
|
224 |
|
case 1: |
225 |
|
/* Unload unneeded modules. */ |
226 |
|
pupa_dl_unload_unneeded (); |
227 |
|
count++; |
228 |
goto again; |
goto again; |
|
} |
|
229 |
|
|
230 |
|
default: |
231 |
|
break; |
232 |
|
} |
233 |
|
|
234 |
pupa_error (PUPA_ERR_OUT_OF_MEMORY, "out of memory"); |
pupa_error (PUPA_ERR_OUT_OF_MEMORY, "out of memory"); |
235 |
return 0; |
return 0; |
236 |
} |
} |