}
}
-static int maps_needed(uint16_t size)
+static int maps_needed(uint16_t top)
{
/* On many platforms if you touch this or PROGTOP you must
touch tricks.s */
- uint16_t needed = size - 1;
+ uint16_t needed = top + 0xFFFF - PROGTOP;
/* Usually we have 0x1000 common - 1 for shift and inc */
needed >>= 13; /* in banks */
needed++; /* rounded */
int pagemap_alloc(ptptr p)
{
uint8_t *ptr;
- int needed = maps_needed(p->p_top - MAPBASE);
+ int needed = maps_needed(p->p_top);
int i;
/* Cheapest way to keep it non zero */
*/
int pagemap_realloc(usize_t code, usize_t size, usize_t stack)
{
- int8_t have = maps_needed(udata.u_top - MAPBASE);
+ int8_t have = maps_needed(udata.u_top);
int8_t want = maps_needed(size);
uint8_t *ptr = (uint8_t *)udata.u_page;