/* Actually build the MSG process */
jstring jname = (jstring)env->GetObjectField(jprocess, jprocess_field_Process_name);
const char* name = env->GetStringUTFChars(jname, 0);
- msg_process_t process = MSG_process_create_from_stdfunc(
- name, [jprocess]() -> void { simgrid::kernel::context::java_main_jprocess(jprocess); },
- /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
+ msg_process_t process =
+ MSG_process_create_from_stdfunc(name, [jprocess]() { simgrid::kernel::context::java_main_jprocess(jprocess); },
+ /*data*/ nullptr, jhost_get_native(env, jhost), /* properties*/ nullptr);
env->ReleaseStringUTFChars(jname, name);
/* bind the java process instance to the native process */
/* Return memory to the heap. */
void mfree(struct mdesc *mdp, void *ptr)
{
- int type;
- size_t block, frag_nb;
+ size_t frag_nb;
size_t i;
int it;
if (ptr == NULL)
return;
- block = BLOCK(ptr);
+ size_t block = BLOCK(ptr);
if ((char *) ptr < (char *) mdp->heapbase || block > mdp->heapsize) {
fprintf(stderr,"Ouch, this pointer is not mine, I refuse to free it. Give me valid pointers, or give me death!!\n");
abort();
}
- type = mdp->heapinfo[block].type;
+ int type = mdp->heapinfo[block].type;
switch (type) {
case MMALLOC_TYPE_HEAPINFO:
mdp -> heapstats.bytes_free +=
mdp -> heapinfo[block].busy_block.size * BLOCKSIZE;
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_block.ignore > 0)
- MC_remove_ignore_heap(ptr, mdp -> heapinfo[block].busy_block.busy_size);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_block.ignore > 0)
+ MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_block.busy_size);
/* Find the free cluster previous to this one in the free list.
Start searching at the last block referenced; this may benefit
THROWF(system_error, 0, "Asked to free a fragment that is already free. I'm puzzled\n");
}
- if(MC_is_active()){
- if(mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
- MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
- }
+ if (MC_is_active() && mdp->heapinfo[block].busy_frag.ignore[frag_nb] > 0)
+ MC_remove_ignore_heap(ptr, mdp->heapinfo[block].busy_frag.frag_size[frag_nb]);
/* Set size used in the fragment to -1 */
mdp->heapinfo[block].busy_frag.frag_size[frag_nb] = -1;
unsuccessful for some reason. */
struct mdesc newmd;
- struct mdesc *mdptr = NULL, *mdptemp = NULL;
+ struct mdesc* mdptr = NULL;
+ struct mdesc* mdptemp = NULL;
if (lseek(fd, 0L, SEEK_SET) != 0)
return NULL;
}
}
- /* NULL is not a valid baseaddr as we cannot map anything there.
- C'mon, user. Think! */
+ /* NULL is not a valid baseaddr as we cannot map anything there. C'mon, user. Think! */
if (baseaddr == NULL)
return (NULL);
- /* We start off with the malloc descriptor allocated on the stack, until
- we build it up enough to call _mmalloc_mmap_morecore() to allocate the
- first page of the region and copy it there. Ensure that it is zero'd and
- then initialize the fields that we know values for. */
+ /* We start off with the malloc descriptor allocated on the stack, until we build it up enough to
+ * call _mmalloc_mmap_morecore() to allocate the first page of the region and copy it there. Ensure that it is
+ * zero'd and then initialize the fields that we know values for. */
mdp = &mtemp;
memset((char *) mdp, 0, sizeof(mtemp));
/* If we have not been passed a valid open file descriptor for the file
to map to, then open /dev/zero and use that to map to. */
- /* Now try to map in the first page, copy the malloc descriptor structure
- there, and arrange to return a pointer to this new copy. If the mapping
- fails, then close the file descriptor if it was opened by us, and arrange
- to return a NULL. */
+ /* Now try to map in the first page, copy the malloc descriptor structure there, and arrange to return a pointer to
+ * this new copy. If the mapping fails, then close the file descriptor if it was opened by us, and arrange to return
+ * a NULL. */
if ((mbase = mmorecore(mdp, sizeof(mtemp))) != NULL) {
memcpy(mbase, mdp, sizeof(mtemp));
}
}
-/** Terminate access to a mmalloc managed region by unmapping all memory pages
- associated with the region, and closing the file descriptor if it is one
- that we opened.
+/** Terminate access to a mmalloc managed region by unmapping all memory pages associated with the region, and closing
+ * the file descriptor if it is one that we opened.
Returns NULL on success.
- 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.
+ 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.
- 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. */
+ 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 *xbt_mheap_destroy(xbt_mheap_t mdp)
{
- struct mdesc mtemp, *mdptemp;
-
if (mdp != NULL) {
/* Remove the heap from the linked list of heaps attached by mmalloc */
- mdptemp = __mmalloc_default_mdp;
+ struct mdesc* mdptemp = __mmalloc_default_mdp;
while(mdptemp->next_mdesc != mdp )
mdptemp = mdptemp->next_mdesc;
mdptemp->next_mdesc = mdp->next_mdesc;
xbt_mheap_destroy_no_free(mdp);
- mtemp = *mdp;
+ struct mdesc mtemp = *mdp;
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
if (mmorecore(&mtemp, (char *)mtemp.base - (char *)mtemp.breakval) == NULL) {
- /* Deallocating failed. Update the original malloc descriptor
- with any changes */
+ /* Deallocating failed. Update the original malloc descriptor with any changes */
*mdp = mtemp;
} else {
if (mtemp.flags & MMALLOC_DEVZERO) {
}
/* Safety gap from the heap's break address.
- * Try to increase this first if you experience strange errors under
- * valgrind. */
+ * Try to increase this first if you experience strange errors under valgrind. */
#define HEAP_OFFSET (128UL<<20)
xbt_mheap_t mmalloc_get_default_md(void)