[tracker/parser-unicode-libs-review] tracker_strhex: avoid unneeded aux char array
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/parser-unicode-libs-review] tracker_strhex: avoid unneeded aux char array
- Date: Wed, 19 May 2010 10:12:36 +0000 (UTC)
commit 43aae5ba3cbe3a63fc50dd8eca6adad7c0046355
Author: Aleksander Morgado <aleksander lanedo com>
Date: Wed May 19 12:10:07 2010 +0200
tracker_strhex: avoid unneeded aux char array
src/libtracker-common/tracker-utils.c | 10 +++-------
1 files changed, 3 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-common/tracker-utils.c b/src/libtracker-common/tracker-utils.c
index 7da50e5..8051662 100644
--- a/src/libtracker-common/tracker-utils.c
+++ b/src/libtracker-common/tracker-utils.c
@@ -170,12 +170,10 @@ tracker_strhex (const guint8 *data,
gsize size,
gchar delimiter)
{
- /* */
gsize i;
gsize j;
gsize new_str_length;
gchar *new_str;
- gchar new_hex_char [3];
/* Get new string length. If input string has N bytes, we need:
* - 1 byte for last NUL char
@@ -189,11 +187,9 @@ tracker_strhex (const guint8 *data,
/* Print hexadecimal representation of each byte... */
for(i=0, j=0; i<size; i++, j+=3) {
- memset (new_hex_char, 0, 3);
- /* Print character in helper array... */
- sprintf (new_hex_char, "%02X", data[i]);
- /* Copy to output string... */
- memcpy (&new_str[j],&new_hex_char[0],2);
+ /* Print character in output string... */
+ snprintf (&new_str[j], 3, "%02X", data[i]);
+
/* And if needed, add separator */
if(i != (size-1) ) {
new_str[j+2] = delimiter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]