summaryrefslogtreecommitdiff
path: root/rbutil/ipodpatcher/ipodio-posix.c
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-12-23 23:30:57 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 15:05:52 +0100
commit24e37ddf57bac6a1c9786d50abbe3a1982930382 (patch)
treeb34ae751986f185f51556a040f388025cac4c383 /rbutil/ipodpatcher/ipodio-posix.c
parent6803d7b10cd9651ded08674f1597d4511cabb7af (diff)
downloadrockbox-24e37ddf57bac6a1c9786d50abbe3a1982930382.tar.gz
rockbox-24e37ddf57bac6a1c9786d50abbe3a1982930382.zip
ipodpatcher: move sectorbuf pointer into ipod_t structure.
The ipod_t structure holds all relevant information for ipodpatcher. Put the global ipod_sectorbuf pointer into it as well. Allows the Rockbox Utility Ipod class to be instanciated multiple times since each instance can now have its own buffer. Change-Id: Ie319cbadbc20c367ceadba9a46b4dc34b57a79a7
Diffstat (limited to 'rbutil/ipodpatcher/ipodio-posix.c')
-rw-r--r--rbutil/ipodpatcher/ipodio-posix.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c
index 8d43de2d60..377510912a 100644
--- a/rbutil/ipodpatcher/ipodio-posix.c
+++ b/rbutil/ipodpatcher/ipodio-posix.c
@@ -358,10 +358,10 @@ int ipod_close(struct ipod_t* ipod)
358 return 0; 358 return 0;
359} 359}
360 360
361int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize) 361int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize)
362{ 362{
363 *sectorbuf=malloc(bufsize); 363 ipod->sectorbuf = malloc(bufsize);
364 if (*sectorbuf == NULL) { 364 if (ipod->sectorbuf== NULL) {
365 return -1; 365 return -1;
366 } 366 }
367 return 0; 367 return 0;
@@ -379,14 +379,20 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos)
379 return 0; 379 return 0;
380} 380}
381 381
382ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) 382ssize_t ipod_read(struct ipod_t* ipod, int nbytes)
383{ 383{
384 return read(ipod->dh, buf, nbytes); 384 if(ipod->sectorbuf == NULL) {
385 return -1;
386 }
387 return read(ipod->dh, ipod->sectorbuf, nbytes);
385} 388}
386 389
387ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) 390ssize_t ipod_write(struct ipod_t* ipod, int nbytes)
388{ 391{
389 return write(ipod->dh, buf, nbytes); 392 if(ipod->sectorbuf == NULL) {
393 return -1;
394 }
395 return write(ipod->dh, ipod->sectorbuf, nbytes);
390} 396}
391 397
392#endif 398#endif