Mercurial > ecos
diff packages/services/memalloc/common/current/src/dlmalloc.cxx @ 159:511f4dc167f6
Merge from eCos master repository on 2001-05-18-01:30:05-BST
| author | jlarmour |
|---|---|
| date | Fri, 18 May 2001 06:32:28 +0000 |
| parents | 6ed91473a1cd |
| children | 0d2b193a635f |
line wrap: on
line diff
--- a/packages/services/memalloc/common/current/src/dlmalloc.cxx +++ b/packages/services/memalloc/common/current/src/dlmalloc.cxx @@ -964,8 +964,14 @@ Cyg_Mempool_dlmalloc_Implementation::Cyg correction = 0; } - top = (mchunkptr)(base + correction); - set_head(top, arenasize | PREV_INUSE); + // too small to be useful? + if ( correction + 2*MALLOC_ALIGNMENT > (unsigned) size ) + // help catch errors. Don't fail now. + arenabase = NULL; + else { + top = (mchunkptr)(base + correction); + set_head(top, arenasize | PREV_INUSE); + } } //---------------------------------------------------------------------------- @@ -1034,6 +1040,11 @@ Cyg_Mempool_dlmalloc_Implementation::try INTERNAL_SIZE_T nb; + /* Allow uninitialised (zero sized) heaps because they could exist as a + * quirk of the MLT setup where a dynamically sized heap is at the top of + * memory. */ + if (NULL==arenabase) return NULL; + if ((long)bytes < 0) return 0; nb = request2size(bytes); /* padded request size; */
