Mercurial > flash_v2
comparison packages/services/memalloc/common/current/src/dlmalloc.cxx @ 1687:eb235374a7ae
2004-06-24 Oyvind Harboe <oyvind.harboe@zylin.com>
* Added cyg_memalloc_alloc_fail() fn which is invoked before
return NULL from failed allocations. Useful breakpoint site.
Andrew Lunn wrote some of the code and pointed out various
wrinkles to be ironed out.
| author | asl |
|---|---|
| date | Mon, 05 Jul 2004 11:07:04 +0000 |
| parents | 28c8c2fbb86e |
| children |
comparison
equal
deleted
inserted
replaced
| 1686:961151dc048e | 1687:eb235374a7ae |
|---|---|
| 213 #include <pkgconf/infra.h> // CYGDBG_USE_ASSERTS | 213 #include <pkgconf/infra.h> // CYGDBG_USE_ASSERTS |
| 214 #include <cyg/infra/cyg_type.h> // types | 214 #include <cyg/infra/cyg_type.h> // types |
| 215 #include <cyg/infra/cyg_ass.h> // assertions | 215 #include <cyg/infra/cyg_ass.h> // assertions |
| 216 #include <stddef.h> // for size_t | 216 #include <stddef.h> // for size_t |
| 217 #include <cyg/memalloc/dlmalloc.hxx> | 217 #include <cyg/memalloc/dlmalloc.hxx> |
| 218 //#include <cyg/infra/diag.h> | |
| 219 | 218 |
| 220 /* | 219 /* |
| 221 Debugging: | 220 Debugging: |
| 222 | 221 |
| 223 Because freed chunks may be overwritten with link fields, this | 222 Because freed chunks may be overwritten with link fields, this |
| 1271 if (chunksize(top) < nb || remainder_size < (long)MINSIZE) | 1270 if (chunksize(top) < nb || remainder_size < (long)MINSIZE) |
| 1272 { | 1271 { |
| 1273 //diag_printf("chunksize(top)=%ld, nb=%d, remainder=%ld\n", chunksize(top), | 1272 //diag_printf("chunksize(top)=%ld, nb=%d, remainder=%ld\n", chunksize(top), |
| 1274 // nb, remainder_size); | 1273 // nb, remainder_size); |
| 1275 MALLOC_UNLOCK; | 1274 MALLOC_UNLOCK; |
| 1275 CYG_MEMALLOC_FAIL(bytes); | |
| 1276 return NULL; /* propagate failure */ | 1276 return NULL; /* propagate failure */ |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 victim = top; | 1279 victim = top; |
| 1280 set_head(victim, nb | PREV_INUSE); | 1280 set_head(victim, nb | PREV_INUSE); |
| 1556 } | 1556 } |
| 1557 } | 1557 } |
| 1558 | 1558 |
| 1559 // couldn't resize the allocation any direction, so return failure | 1559 // couldn't resize the allocation any direction, so return failure |
| 1560 MALLOC_UNLOCK; | 1560 MALLOC_UNLOCK; |
| 1561 CYG_MEMALLOC_FAIL(bytes); | |
| 1561 return NULL; | 1562 return NULL; |
| 1562 } | 1563 } |
| 1563 | 1564 |
| 1564 | 1565 |
| 1565 split: /* split off extra room in old or expanded chunk */ | 1566 split: /* split off extra room in old or expanded chunk */ |
