mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-20 10:32:42 -05:00
sansapatcher: move sectorbuf pointer into sansa_t structure.
Similar as the ipod_t structure for ipodpatcher the sansa_t structure holds all relevant information for sansapatcher. Put the global sansa_sectorbuf pointer into it as well. Change-Id: Iad08ef6aafc49609c3d0d556914246f230ee0179
This commit is contained in:
parent
24e37ddf57
commit
9c1ed84d28
9 changed files with 77 additions and 97 deletions
|
|
@ -150,12 +150,12 @@ int sansa_close(struct sansa_t* sansa)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int sansa_alloc_buffer(unsigned char** sectorbuf, int bufsize)
|
||||
int sansa_alloc_buffer(struct sansa_t* sansa, int bufsize)
|
||||
{
|
||||
/* The ReadFile function requires a memory buffer aligned to a multiple of
|
||||
the disk sector size. */
|
||||
*sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (*sectorbuf == NULL) {
|
||||
sansa->sectorbuf = (unsigned char*)VirtualAlloc(NULL, bufsize, MEM_COMMIT, PAGE_READWRITE);
|
||||
if (sansa->sectorbuf == NULL) {
|
||||
sansa_print_error(" Error allocating a buffer: ");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -189,11 +189,11 @@ int sansa_read(struct sansa_t* sansa, unsigned char* buf, int nbytes)
|
|||
return count;
|
||||
}
|
||||
|
||||
int sansa_write(struct sansa_t* sansa, unsigned char* buf, int nbytes)
|
||||
int sansa_write(struct sansa_t* sansa, int nbytes)
|
||||
{
|
||||
unsigned long count;
|
||||
|
||||
if (!WriteFile(sansa->dh, buf, nbytes, &count, NULL)) {
|
||||
if (!WriteFile(sansa->dh, sansa->sectorbuf, nbytes, &count, NULL)) {
|
||||
sansa_print_error(" Error writing to disk: ");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue