summaryrefslogtreecommitdiff
path: root/rbutil/ipodpatcher
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 11:04:21 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 15:06:41 +0100
commitb63d429c8f2c68994600d98bfaddf59ca16fc889 (patch)
tree6cd4d216f57f28d95faf96a913188646f5527909 /rbutil/ipodpatcher
parent45cda1fdcc963db4824224af362de780e0d29097 (diff)
downloadrockbox-b63d429c8f2c68994600d98bfaddf59ca16fc889.tar.gz
rockbox-b63d429c8f2c68994600d98bfaddf59ca16fc889.zip
Provide dealloc function to ipodpatcher.
On Windows the sector buffer is allocated using VirtualAlloc, thus releasing this buffer should be done using VirtualFree. Provide an additional function for deallocating the buffer so users of ipodpatcher do not need to know about this. Change-Id: Ibb0fc575a185148a389e63935e86a392bf8d180d
Diffstat (limited to 'rbutil/ipodpatcher')
-rw-r--r--rbutil/ipodpatcher/ipodio-posix.c10
-rw-r--r--rbutil/ipodpatcher/ipodio-win32.c13
-rw-r--r--rbutil/ipodpatcher/ipodio.h1
-rw-r--r--rbutil/ipodpatcher/main.c1
4 files changed, 25 insertions, 0 deletions
diff --git a/rbutil/ipodpatcher/ipodio-posix.c b/rbutil/ipodpatcher/ipodio-posix.c
index 377510912a..59cbc0188e 100644
--- a/rbutil/ipodpatcher/ipodio-posix.c
+++ b/rbutil/ipodpatcher/ipodio-posix.c
@@ -367,6 +367,16 @@ int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize)
367 return 0; 367 return 0;
368} 368}
369 369
370int ipod_dealloc_buffer(struct ipod_t* ipod)
371{
372 if (ipod->sectorbuf == NULL) {
373 return -1;
374 }
375 free(ipod->sectorbuf);
376 ipod->sectorbuf = NULL;
377 return 0;
378}
379
370int ipod_seek(struct ipod_t* ipod, unsigned long pos) 380int ipod_seek(struct ipod_t* ipod, unsigned long pos)
371{ 381{
372 off_t res; 382 off_t res;
diff --git a/rbutil/ipodpatcher/ipodio-win32.c b/rbutil/ipodpatcher/ipodio-win32.c
index d4bdbf0173..cea218774a 100644
--- a/rbutil/ipodpatcher/ipodio-win32.c
+++ b/rbutil/ipodpatcher/ipodio-win32.c
@@ -170,6 +170,19 @@ int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize)
170 return 0; 170 return 0;
171} 171}
172 172
173int ipod_dealloc_buffer(struct ipod_t* ipod)
174{
175 if (ipod->sectorbuf == NULL) {
176 return -1;
177 }
178 if(!VirtualFree(ipod->sectorbuf, 0, MEM_RELEASE)) {
179 ipod_print_error(" Error releasing buffer ");
180 return -1;
181 }
182 ipod->sectorbuf = NULL;
183 return 0;
184}
185
173int ipod_seek(struct ipod_t* ipod, unsigned long pos) 186int ipod_seek(struct ipod_t* ipod, unsigned long pos)
174{ 187{
175 if (SetFilePointer(ipod->dh, pos, NULL, FILE_BEGIN)==0xffffffff) { 188 if (SetFilePointer(ipod->dh, pos, NULL, FILE_BEGIN)==0xffffffff) {
diff --git a/rbutil/ipodpatcher/ipodio.h b/rbutil/ipodpatcher/ipodio.h
index 8a2f06cf20..4f1a35dd09 100644
--- a/rbutil/ipodpatcher/ipodio.h
+++ b/rbutil/ipodpatcher/ipodio.h
@@ -107,6 +107,7 @@ int ipod_scsi_inquiry(struct ipod_t* ipod, int page_code,
107ssize_t ipod_read(struct ipod_t* ipod, int nbytes); 107ssize_t ipod_read(struct ipod_t* ipod, int nbytes);
108ssize_t ipod_write(struct ipod_t* ipod, int nbytes); 108ssize_t ipod_write(struct ipod_t* ipod, int nbytes);
109int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize); 109int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize);
110int ipod_dealloc_buffer(struct ipod_t* ipod);
110 111
111/* In fat32format.c */ 112/* In fat32format.c */
112int format_partition(struct ipod_t* ipod, int partition); 113int format_partition(struct ipod_t* ipod, int partition);
diff --git a/rbutil/ipodpatcher/main.c b/rbutil/ipodpatcher/main.c
index 12c38de704..e82fbf53f3 100644
--- a/rbutil/ipodpatcher/main.c
+++ b/rbutil/ipodpatcher/main.c
@@ -614,5 +614,6 @@ int main(int argc, char* argv[])
614 } 614 }
615#endif 615#endif
616 616
617 ipod_dealloc_buffer(&ipod);
617 return 0; 618 return 0;
618} 619}