From 24e37ddf57bac6a1c9786d50abbe3a1982930382 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 23 Dec 2012 23:30:57 +0100 Subject: 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 --- rbutil/ipodpatcher/ipodio-posix.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'rbutil/ipodpatcher/ipodio-posix.c') 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) return 0; } -int ipod_alloc_buffer(unsigned char** sectorbuf, int bufsize) +int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize) { - *sectorbuf=malloc(bufsize); - if (*sectorbuf == NULL) { + ipod->sectorbuf = malloc(bufsize); + if (ipod->sectorbuf== NULL) { return -1; } return 0; @@ -379,14 +379,20 @@ int ipod_seek(struct ipod_t* ipod, unsigned long pos) return 0; } -ssize_t ipod_read(struct ipod_t* ipod, unsigned char* buf, int nbytes) +ssize_t ipod_read(struct ipod_t* ipod, int nbytes) { - return read(ipod->dh, buf, nbytes); + if(ipod->sectorbuf == NULL) { + return -1; + } + return read(ipod->dh, ipod->sectorbuf, nbytes); } -ssize_t ipod_write(struct ipod_t* ipod, unsigned char* buf, int nbytes) +ssize_t ipod_write(struct ipod_t* ipod, int nbytes) { - return write(ipod->dh, buf, nbytes); + if(ipod->sectorbuf == NULL) { + return -1; + } + return write(ipod->dh, ipod->sectorbuf, nbytes); } #endif -- cgit v1.2.3