Rockbox

Tasklist

FS#7740 - Chess:error in pl_malloc,missing update of remaining size in plugin buffer for pseudo dynamic alloc.

Attached to Project: Rockbox
Opened by Daniel WECK (daniel.weck) - Sunday, 09 September 2007, 20:06 GMT
Last edited by Jonathan Gordon (jdgordon) - Tuesday, 19 August 2008, 12:16 GMT
Task Type Bugs
Category Games
Status Closed
Assigned To No-one
Operating System All players
Severity Low
Priority Normal
Reported Version Daily build (which?)
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

In chessbox_pgn.c, the bufleft variable is never updated to reflect the actual size left in the plugin buffer for pseudo dynamic allocation. The original code is:

---------
/* global vars for pl_malloc() */
void *bufptr = NULL;
ssize_t bufleft;

/* simple function to "allocate" memory in pluginbuffer.
* (borrowed from dict.c)
*/
void *pl_malloc(ssize_t size)
{
void *ptr;
ptr = bufptr;

if (bufleft < size)
{
return NULL;
}
else
{
bufptr += size;
return ptr;
}
}

/* init function for pl_malloc() */
void pl_malloc_init(void)
{
bufptr = rb->plugin_get_buffer((size_t *)&bufleft);
}
---------

In pl_malloc(), the bufleft variable should be updated as such:


---------
...
else
{
bufptr += size;


>>>>>>>> bufleft -= size;


return ptr;
}
...
---------
This task depends upon

Closed by  Jonathan Gordon (jdgordon)
Tuesday, 19 August 2008, 12:16 GMT
Reason for closing:  Accepted
Additional comments about closing:  thanks :)
Comment by Daniel WECK (daniel.weck) - Sunday, 09 September 2007, 20:27 GMT
I forgot to say: this code is copied from dict.c, so the both the Chess and Dict plugins are affected by this.

Loading...