Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

55 lines (45 sloc) 0.833 kB
namespace factor
{
template<typename Block> struct bump_allocator {
/* offset of 'here' and 'end' is hardcoded in compiler backends */
cell here;
cell start;
cell end;
cell size;
explicit bump_allocator(cell size_, cell start_) :
here(start_), start(start_), end(start_ + size_), size(size_) {}
bool contains_p(Block *block)
{
return ((cell)block - start) < size;
}
Block *allot(cell size)
{
cell h = here;
here = h + align(size,data_alignment);
return (Block *)h;
}
cell occupied_space()
{
return here - start;
}
cell free_space()
{
return end - here;
}
cell next_object_after(cell scan)
{
cell size = ((Block *)scan)->size();
if(scan + size < here)
return scan + size;
else
return 0;
}
cell first_object()
{
if(start != here)
return start;
else
return 0;
}
};
}
Jump to Line
Something went wrong with that request. Please try again.