Skip to content

Commit

Permalink
Assert on bad arguments to sgen_clear_range.
Browse files Browse the repository at this point in the history
  • Loading branch information
kumpera committed Jun 25, 2012
1 parent f4dfaf0 commit b5b0f8a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions mono/metadata/sgen-nursery-allocator.c
Expand Up @@ -661,12 +661,24 @@ sgen_clear_nursery_fragments (void)
}
}

/*
* Mark a given range of memory as invalid.
*
* This can be done either by zeroing memory or by placing
* a phony byte[] array. This keeps the heap forward walkable.
*
* This function ignores calls with a zero range, even if
* both start and end are NULL.
*/
void
sgen_clear_range (char *start, char *end)
{
MonoArray *o;
size_t size = end - start;

if ((start && !end) || (start > end))
g_error ("Invalid range [%p %p]", start, end);

if (size < sizeof (MonoArray)) {
memset (start, 0, size);
return;
Expand Down

0 comments on commit b5b0f8a

Please sign in to comment.