summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher
diff options
context:
space:
mode:
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)
return 0;
}
+int ipod_dealloc_buffer(struct ipod_t* ipod)
+{
+ if (ipod->sectorbuf == NULL) {
+ return -1;
+ }
+ free(ipod->sectorbuf);
+ ipod->sectorbuf = NULL;
+ return 0;
+}
+
int ipod_seek(struct ipod_t* ipod, unsigned long pos)
{
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)
return 0;
}
+int ipod_dealloc_buffer(struct ipod_t* ipod)
+{
+ if (ipod->sectorbuf == NULL) {
+ return -1;
+ }
+ if(!VirtualFree(ipod->sectorbuf, 0, MEM_RELEASE)) {
+ ipod_print_error(" Error releasing buffer ");
+ return -1;
+ }
+ ipod->sectorbuf = NULL;
+ return 0;
+}
+
int ipod_seek(struct ipod_t* ipod, unsigned long pos)
{
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,
ssize_t ipod_read(struct ipod_t* ipod, int nbytes);
ssize_t ipod_write(struct ipod_t* ipod, int nbytes);
int ipod_alloc_buffer(struct ipod_t* ipod, int bufsize);
+int ipod_dealloc_buffer(struct ipod_t* ipod);
/* In fat32format.c */
int 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[])
}
#endif
+ ipod_dealloc_buffer(&ipod);
return 0;
}