summaryrefslogtreecommitdiff
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 13:23:47 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 15:06:41 +0100
commit163ab4617096edb6384aa8fc7a764d440aee3fb9 (patch)
treeca0e49f5c184aa4def60bcca7f17f0653f45eb6e /rbutil
parenta8d291bd20428a59d29b886b7b1403261f9e5af3 (diff)
downloadrockbox-163ab4617096edb6384aa8fc7a764d440aee3fb9.tar.gz
rockbox-163ab4617096edb6384aa8fc7a764d440aee3fb9.zip
Provide dealloc function to sansapatcher.
Similar as done with ipodpatcher provide a function to free the allocated sector buffer. Change-Id: Ie51e82f7191496bb48973148af1cc35cd37993d3
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/autodetection.cpp3
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallsansa.cpp3
-rw-r--r--rbutil/sansapatcher/main.c1
-rw-r--r--rbutil/sansapatcher/sansaio-posix.c10
-rw-r--r--rbutil/sansapatcher/sansaio-win32.c13
-rw-r--r--rbutil/sansapatcher/sansaio.h1
6 files changed, 27 insertions, 4 deletions
diff --git a/rbutil/rbutilqt/base/autodetection.cpp b/rbutil/rbutilqt/base/autodetection.cpp
index e57c4542d0..4144cca19d 100644
--- a/rbutil/rbutilqt/base/autodetection.cpp
+++ b/rbutil/rbutilqt/base/autodetection.cpp
@@ -185,8 +185,7 @@ bool Autodetection::detect()
185 else { 185 else {
186 qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n; 186 qDebug() << "[Autodetect] sansapatcher: no Sansa found." << n;
187 } 187 }
188 free(sansa.sectorbuf); 188 sansa_dealloc_buffer(&sansa);
189 sansa.sectorbuf = NULL;
190 189
191 if(m_mountpoint.isEmpty() && m_device.isEmpty() 190 if(m_mountpoint.isEmpty() && m_device.isEmpty()
192 && m_errdev.isEmpty() && m_incompat.isEmpty()) 191 && m_errdev.isEmpty() && m_incompat.isEmpty())
diff --git a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
index 061ec2578f..49099ebaf8 100644
--- a/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
+++ b/rbutil/rbutilqt/base/bootloaderinstallsansa.cpp
@@ -36,8 +36,7 @@ BootloaderInstallSansa::BootloaderInstallSansa(QObject *parent)
36BootloaderInstallSansa::~BootloaderInstallSansa() 36BootloaderInstallSansa::~BootloaderInstallSansa()
37{ 37{
38 if(sansa.sectorbuf) { 38 if(sansa.sectorbuf) {
39 free(sansa.sectorbuf); 39 sansa_dealloc_buffer(&sansa);
40 sansa.sectorbuf = NULL;
41 } 40 }
42} 41}
43 42
diff --git a/rbutil/sansapatcher/main.c b/rbutil/sansapatcher/main.c
index 743ebfedbd..29c2f915bb 100644
--- a/rbutil/sansapatcher/main.c
+++ b/rbutil/sansapatcher/main.c
@@ -404,6 +404,7 @@ int main(int argc, char* argv[])
404 } 404 }
405 405
406 sansa_close(&sansa); 406 sansa_close(&sansa);
407 sansa_dealloc_buffer(&sansa);
407 408
408 if (action==INTERACTIVE) { 409 if (action==INTERACTIVE) {
409 printf("Press ENTER to exit sansapatcher :"); 410 printf("Press ENTER to exit sansapatcher :");
diff --git a/rbutil/sansapatcher/sansaio-posix.c b/rbutil/sansapatcher/sansaio-posix.c
index d173fbc300..44c4dcc95c 100644
--- a/rbutil/sansapatcher/sansaio-posix.c
+++ b/rbutil/sansapatcher/sansaio-posix.c
@@ -122,6 +122,16 @@ int sansa_alloc_buffer(struct sansa_t *sansa, int bufsize)
122 return 0; 122 return 0;
123} 123}
124 124
125int sansa_dealloc_buffer(struct sansa_t* sansa)
126{
127 if (sansa->sectorbuf == NULL) {
128 return -1;
129 }
130 free(sansa->sectorbuf);
131 sansa->sectorbuf = NULL;
132 return 0;
133}
134
125int sansa_seek(struct sansa_t* sansa, loff_t pos) 135int sansa_seek(struct sansa_t* sansa, loff_t pos)
126{ 136{
127 off_t res; 137 off_t res;
diff --git a/rbutil/sansapatcher/sansaio-win32.c b/rbutil/sansapatcher/sansaio-win32.c
index 256712fe20..ee6a8cd93d 100644
--- a/rbutil/sansapatcher/sansaio-win32.c
+++ b/rbutil/sansapatcher/sansaio-win32.c
@@ -162,6 +162,19 @@ int sansa_alloc_buffer(struct sansa_t* sansa, int bufsize)
162 return 0; 162 return 0;
163} 163}
164 164
165int sansa_dealloc_buffer(struct sansa_t* sansa)
166{
167 if (sansa->sectorbuf == NULL) {
168 return -1;
169 }
170 if(!VirtualFree(sansa->sectorbuf, 0, MEM_RELEASE)) {
171 sansa_print_error(" Error releasing buffer ");
172 return -1;
173 }
174 sansa->sectorbuf = NULL;
175 return 0;
176}
177
165int sansa_seek(struct sansa_t* sansa, loff_t pos) 178int sansa_seek(struct sansa_t* sansa, loff_t pos)
166{ 179{
167 LARGE_INTEGER li; 180 LARGE_INTEGER li;
diff --git a/rbutil/sansapatcher/sansaio.h b/rbutil/sansapatcher/sansaio.h
index 9e8ebb93c9..61e2f1d1b2 100644
--- a/rbutil/sansapatcher/sansaio.h
+++ b/rbutil/sansapatcher/sansaio.h
@@ -80,6 +80,7 @@ int sansa_seek(struct sansa_t* sansa, loff_t pos);
80int sansa_read(struct sansa_t* sansa, unsigned char* buf, int nbytes); 80int sansa_read(struct sansa_t* sansa, unsigned char* buf, int nbytes);
81int sansa_write(struct sansa_t* sansa, int nbytes); 81int sansa_write(struct sansa_t* sansa, int nbytes);
82int sansa_alloc_buffer(struct sansa_t* sansa, int bufsize); 82int sansa_alloc_buffer(struct sansa_t* sansa, int bufsize);
83int sansa_dealloc_buffer(struct sansa_t* sansa);
83 84
84#ifdef __cplusplus 85#ifdef __cplusplus
85} 86}