From: Martin Quinson Date: Thu, 2 Feb 2012 14:12:20 +0000 (+0100) Subject: normalize the function names wrt to the rest of XBT X-Git-Tag: exp_20120216~86 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/907588ad7c14cc210e2f2a072b72bc1b91133ca0?ds=sidebyside normalize the function names wrt to the rest of XBT --- diff --git a/include/xbt/mmalloc.h b/include/xbt/mmalloc.h index f6ca9056e8..53d0c84453 100644 --- a/include/xbt/mmalloc.h +++ b/include/xbt/mmalloc.h @@ -46,11 +46,11 @@ extern void *mmemalign(xbt_mheap_t md, size_t alignment, size_t size); /* Allocate SIZE bytes on a page boundary. */ extern void *mvalloc(xbt_mheap_t md, size_t size); -extern xbt_mheap_t mmalloc_attach(int fd, void *baseaddr); +extern xbt_mheap_t xbt_mheap_new(int fd, void *baseaddr); -extern void mmalloc_detach_no_free(xbt_mheap_t md); +extern void xbt_mheap_destroy_no_free(xbt_mheap_t md); -extern void *mmalloc_detach(xbt_mheap_t md); +extern void *xbt_mheap_destroy(xbt_mheap_t md); /* return the heap used when NULL is passed as first argument to any mm* function */ extern xbt_mheap_t mmalloc_get_default_md(void); diff --git a/src/mc/mc_memory.c b/src/mc/mc_memory.c index 71eb7d0593..1950729fcc 100644 --- a/src/mc/mc_memory.c +++ b/src/mc/mc_memory.c @@ -28,7 +28,7 @@ void MC_memory_init() xbt_assert(std_heap != NULL); /* Create the second region a page after the first one ends + safety gap */ - raw_heap = mmalloc_attach(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize()); + raw_heap = xbt_mheap_new(-1, (char*)(std_heap) + STD_HEAP_SIZE + getpagesize()); xbt_assert(raw_heap != NULL); } @@ -37,5 +37,5 @@ void MC_memory_init() void MC_memory_exit(void) { if (raw_heap) - mmalloc_detach(raw_heap); + xbt_mheap_destroy(raw_heap); } diff --git a/src/xbt/mmalloc/mm_module.c b/src/xbt/mmalloc/mm_module.c index 7aea0c18dd..8ec8e73a0d 100644 --- a/src/xbt/mmalloc/mm_module.c +++ b/src/xbt/mmalloc/mm_module.c @@ -64,7 +64,7 @@ Boston, MA 02111-1307, USA. */ On failure returns NULL. */ -xbt_mheap_t mmalloc_attach(int fd, void *baseaddr) +xbt_mheap_t xbt_mheap_new(int fd, void *baseaddr) { struct mdesc mtemp; xbt_mheap_t mdp; @@ -207,7 +207,7 @@ xbt_mheap_t mmalloc_attach(int fd, void *baseaddr) * This is for example useful for the base region where ldl stores its data * because it leaves the place after us. */ -void mmalloc_detach_no_free(xbt_mheap_t md) +void xbt_mheap_destroy_no_free(xbt_mheap_t md) { struct mdesc *mdp = md; @@ -225,13 +225,13 @@ void mmalloc_detach_no_free(xbt_mheap_t md) Returns the malloc descriptor on failure, which can subsequently be used for further action, such as obtaining more information about the nature of - the failure by examining the preserved errno value. + the failure. Note that the malloc descriptor that we are using is currently located in region we are about to unmap, so we first make a local copy of it on the stack and use the copy. */ -void *mmalloc_detach(xbt_mheap_t mdp) +void *xbt_mheap_destroy(xbt_mheap_t mdp) { struct mdesc mtemp, *mdptemp; @@ -243,7 +243,7 @@ void *mmalloc_detach(xbt_mheap_t mdp) mdptemp->next_mdesc = mdp->next_mdesc; - mmalloc_detach_no_free(mdp); + xbt_mheap_destroy_no_free(mdp); mtemp = *mdp; /* Now unmap all the pages associated with this region by asking for a @@ -323,7 +323,7 @@ void *mmalloc_preinit(void) if (__mmalloc_default_mdp == NULL) { unsigned long mask = ~((unsigned long)getpagesize() - 1); void *addr = (void*)(((unsigned long)sbrk(0) + HEAP_OFFSET) & mask); - __mmalloc_default_mdp = mmalloc_attach(-1, addr); + __mmalloc_default_mdp = xbt_mheap_new(-1, addr); /* Fixme? only the default mdp in protected against forks */ res = xbt_os_thread_atfork(mmalloc_fork_prepare, mmalloc_fork_parent, mmalloc_fork_child); @@ -339,5 +339,5 @@ void mmalloc_postexit(void) { /* Do not detach the default mdp or ldl won't be able to free the memory it allocated since we're in memory */ // mmalloc_detach(__mmalloc_default_mdp); - mmalloc_detach_no_free(__mmalloc_default_mdp); + xbt_mheap_destroy_no_free(__mmalloc_default_mdp); } diff --git a/src/xbt/mmalloc/test/mmalloc_test.c b/src/xbt/mmalloc/test/mmalloc_test.c index 2f384e73b4..59c4a2430b 100644 --- a/src/xbt/mmalloc/test/mmalloc_test.c +++ b/src/xbt/mmalloc/test/mmalloc_test.c @@ -26,7 +26,7 @@ int main() assert(fd1>0); */ - heapA = mmalloc_attach(-1, sbrk(0) + BUFFSIZE); + heapA = xbt_mheap_new(-1, sbrk(0) + BUFFSIZE); if (heapA == NULL) { perror("attach 1 failed"); fprintf(stderr, "bye\n");