[gnome-commander] intviewer: use reference to array_length in convert_utf8_to_chartype_array()
- From: Piotr Eljasiak <epiotr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] intviewer: use reference to array_length in convert_utf8_to_chartype_array()
- Date: Mon, 9 Jan 2012 19:02:34 +0000 (UTC)
commit e4d66d8911398fe2070058dbde547db5feff7190
Author: Piotr Eljasiak <epiotr src gnome org>
Date: Mon Jan 9 20:01:38 2012 +0100
intviewer: use reference to array_length in convert_utf8_to_chartype_array()
src/intviewer/bm_chartype.cc | 2 +-
src/intviewer/viewer-utils.cc | 6 ++----
src/intviewer/viewer-utils.h | 2 +-
tests/gviewer/bm_chartype_test.c | 2 +-
4 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/intviewer/bm_chartype.cc b/src/intviewer/bm_chartype.cc
index b2c9f0e..40ac124 100644
--- a/src/intviewer/bm_chartype.cc
+++ b/src/intviewer/bm_chartype.cc
@@ -123,7 +123,7 @@ GViewerBMChartypeData *create_bm_chartype_data(const gchar *pattern, gboolean ca
data->case_sensitive = case_sensitive;
- data->pattern = convert_utf8_to_chartype_array(pattern, &data->pattern_len);
+ data->pattern = convert_utf8_to_chartype_array(pattern, data->pattern_len);
if (!data->pattern)
goto error;
diff --git a/src/intviewer/viewer-utils.cc b/src/intviewer/viewer-utils.cc
index 12d16f9..d0ecf5b 100644
--- a/src/intviewer/viewer-utils.cc
+++ b/src/intviewer/viewer-utils.cc
@@ -98,11 +98,9 @@ int unicode2utf8 (unsigned int unicode, unsigned char *out)
}
-char_type *convert_utf8_to_chartype_array (const gchar *utf8text, /*out*/ int *array_length)
+char_type *convert_utf8_to_chartype_array (const gchar *utf8text, /*out*/ int &array_length)
{
g_return_val_if_fail (utf8text!=NULL, NULL);
- g_return_val_if_fail (array_length!=NULL, NULL);
-
g_return_val_if_fail (g_utf8_validate(utf8text, -1, NULL), NULL);
guint32 unicode_char;
@@ -110,8 +108,8 @@ char_type *convert_utf8_to_chartype_array (const gchar *utf8text, /*out*/ int *a
glong length = g_utf8_strlen(utf8text, -1);
g_return_val_if_fail (length>0, NULL);
- *array_length = length;
char_type *result = g_new0 (char_type, length);
+ array_length = length;
const gchar *pos = utf8text;
diff --git a/src/intviewer/viewer-utils.h b/src/intviewer/viewer-utils.h
index 4e4ebaa..59fc980 100644
--- a/src/intviewer/viewer-utils.h
+++ b/src/intviewer/viewer-utils.h
@@ -32,7 +32,7 @@ gint gviewer_get_int (const gchar *path, int def);
gboolean gviewer_get_bool (const gchar *path, gboolean def);
int unicode2utf8(unsigned int unicode, unsigned char *out);
-char_type *convert_utf8_to_chartype_array(const gchar *utf8text, /*out*/ int *array_length);
+char_type *convert_utf8_to_chartype_array(const gchar *utf8text, /*out*/ int &array_length);
guint8 *mem_reverse(const guint8 *buffer, guint buflen);
diff --git a/tests/gviewer/bm_chartype_test.c b/tests/gviewer/bm_chartype_test.c
index 3b89618..6e45818 100644
--- a/tests/gviewer/bm_chartype_test.c
+++ b/tests/gviewer/bm_chartype_test.c
@@ -84,7 +84,7 @@ int main()
printf("(All other characters have value of %d)\n\n", data->pattern_len);
// Convert the UTF8 text string to a chartype array
- ct_text = convert_utf8_to_chartype_array(text, &ct_text_len);
+ ct_text = convert_utf8_to_chartype_array(text, ct_text_len);
if (!ct_text) {
fprintf(stderr,"failed to convert text to 'char_type' array (maybe 'text' is not a valid UTF8 string?)\n");
exit(-1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]