tracker r2158 - in branches/indexer-split: . src/tracker-indexer
- From: carlosg svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2158 - in branches/indexer-split: . src/tracker-indexer
- Date: Tue, 26 Aug 2008 16:17:55 +0000 (UTC)
Author: carlosg
Date: Tue Aug 26 16:17:55 2008
New Revision: 2158
URL: http://svn.gnome.org/viewvc/tracker?rev=2158&view=rev
Log:
2008-08-26 Carlos Garnacho <carlos imendio com>
* src/tracker-indexer/tracker-metadata-utils.c (get_file_content):
Don't allocate in the stack so much memory, even more when it's going
to be copied around.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c
Modified: branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c
==============================================================================
--- branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c (original)
+++ branches/indexer-split/src/tracker-indexer/tracker-metadata-utils.c Tue Aug 26 16:17:55 2008
@@ -38,6 +38,8 @@
#define METADATA_FILE_MODIFIED "File:Modified"
#define METADATA_FILE_ACCESSED "File:Accessed"
+#define TEXT_MAX_SIZE 1048576
+
typedef struct {
GPid pid;
GIOChannel *stdin_channel;
@@ -424,8 +426,9 @@
GError *error = NULL;
gssize bytes_read;
gssize bytes_remaining;
- gchar buf[1048576];
+ gchar *buf;
+ buf = g_new (gchar, TEXT_MAX_SIZE);
file = g_file_new_for_path (path);
stream = g_file_read (file, NULL, &error);
@@ -440,8 +443,7 @@
}
/* bytes_max = tracker_config_get_max_text_to_index (config); */
- bytes_remaining = sizeof (buf);
- memset (buf, 0, bytes_remaining);
+ bytes_remaining = TEXT_MAX_SIZE;
/* NULL termination */
bytes_remaining--;
@@ -462,18 +464,21 @@
g_error_free (error);
g_object_unref (file);
g_object_unref (stream);
+ g_free (buf);
return NULL;
}
+ buf [TEXT_MAX_SIZE - bytes_remaining] = '\0';
+
g_object_unref (file);
g_object_unref (stream);
g_debug ("Read %d bytes from file:'%s'\n",
- sizeof (buf) - bytes_remaining,
+ TEXT_MAX_SIZE - bytes_remaining,
path);
- return g_strdup (buf);
+ return buf;
}
gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]