[gnome-commander] intviewer: use reference to buflen in text2hex()
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] intviewer: use reference to buflen in text2hex()
- Date: Wed, 11 Jan 2012 18:23:36 +0000 (UTC)
commit 1caa485c6c1497bf3cc3493bb32c6229be202901
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Wed Jan 11 19:23:02 2012 +0100
intviewer: use reference to buflen in text2hex()
src/intviewer/search-dlg.cc | 4 ++--
src/intviewer/viewer-utils.cc | 5 ++---
src/intviewer/viewer-utils.h | 2 +-
tests/gviewer/utils_test.c | 2 +-
4 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/intviewer/search-dlg.cc b/src/intviewer/search-dlg.cc
index 248d6c6..16f9e88 100644
--- a/src/intviewer/search-dlg.cc
+++ b/src/intviewer/search-dlg.cc
@@ -185,7 +185,7 @@ static void search_dlg_action_response (GtkDialog *dlg, gint arg1, GViewerSearch
}
else // hex mode search
{
- sdlg->priv->search_hex_buffer = text2hex(pattern, &sdlg->priv->search_hex_buflen);
+ sdlg->priv->search_hex_buffer = text2hex (pattern, sdlg->priv->search_hex_buflen);
g_return_if_fail (sdlg->priv->search_hex_buffer!=NULL);
gnome_cmd_data.intviewer_defaults.hex_patterns.add(pattern);
@@ -215,7 +215,7 @@ void entry_changed (GtkEntry *entry, gpointer user_data)
{
// Only if the use entered a valid hex string, enable the "find" button
guint len;
- guint8 *buf = text2hex (gtk_entry_get_text (entry), &len);
+ guint8 *buf = text2hex (gtk_entry_get_text (entry), len);
enable = buf!=NULL && len>0;
g_free (buf);
diff --git a/src/intviewer/viewer-utils.cc b/src/intviewer/viewer-utils.cc
index d0ecf5b..12f01a7 100644
--- a/src/intviewer/viewer-utils.cc
+++ b/src/intviewer/viewer-utils.cc
@@ -147,10 +147,9 @@ guint8 *mem_reverse (const guint8 *buffer, guint buflen)
}
-guint8 *text2hex (const gchar *text, /*out*/ guint *buflen)
+guint8 *text2hex (const gchar *text, /*out*/ guint &buflen)
{
g_return_val_if_fail (text!=NULL, NULL);
- g_return_val_if_fail (buflen!=NULL, NULL);
guint8 *result;
int len;
@@ -192,6 +191,6 @@ guint8 *text2hex (const gchar *text, /*out*/ guint *buflen)
}
high_nib = !high_nib;
};
- *buflen = len;
+ buflen = len;
return result;
}
diff --git a/src/intviewer/viewer-utils.h b/src/intviewer/viewer-utils.h
index 59fc980..f1ff5ba 100644
--- a/src/intviewer/viewer-utils.h
+++ b/src/intviewer/viewer-utils.h
@@ -37,7 +37,7 @@ char_type *convert_utf8_to_chartype_array(const gchar *utf8text, /*out*/ int &ar
guint8 *mem_reverse(const guint8 *buffer, guint buflen);
/* returns NULL if 'text' is not a valid hex string (whitespaces are OK, and are ignored) */
-guint8 *text2hex(const gchar *text, /*out*/ guint *buflen);
+guint8 *text2hex (const gchar *text, /*out*/ guint &buflen);
/* if "ch" is lower case english letter (a-z), returns UPPER case letter, otherwise returns unmodified "ch" */
inline char_type chartype_toupper(char_type ch)
diff --git a/tests/gviewer/utils_test.c b/tests/gviewer/utils_test.c
index 3ea175e..4ea4e9c 100644
--- a/tests/gviewer/utils_test.c
+++ b/tests/gviewer/utils_test.c
@@ -11,7 +11,7 @@ void test_text2hex()
const gchar *text = "00 0102 03 04 05 06 AA BB CC FE";
guint len;
- guint8 *buf = text2hex(text,&len);
+ guint8 *buf = text2hex (text,len);
for (int i=0; i<len; ++i)
printf("%02x ", buf[i]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]