aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNotZed <NotZed@HelixCode.com>2000-05-05 16:47:02 +0800
committerMichael Zucci <zucchi@src.gnome.org>2000-05-05 16:47:02 +0800
commitaa7851f1f03b4dbcf5b464b535ae71c50536f430 (patch)
treecc463f8ae82075b753c4ac93f246c3b7db372771
parent022c7ab1f28ac677a60cbffa54be28e3272f1c2d (diff)
downloadgsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar.gz
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar.bz2
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar.lz
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar.xz
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.tar.zst
gsoc2013-evolution-aa7851f1f03b4dbcf5b464b535ae71c50536f430.zip
And same here ...
2000-05-05 NotZed <NotZed@HelixCode.com> * camel-folder-summary.c: And same here ... * camel-mime-utils.c: Defined out some memory profiling stuff I left there by mistake. * camel-mime-parser.c (folder_scan_content): Apply the fix from the header scanner to here too. (folder_scan_header): Only check for end of header if we have space for it (didn't end the read with a newline) (folder_scan_header): inptr is the only real thing we need registerised for performance. Try to help the compiler be smart about it .. (folder_scan_header): Simplified the save header case a tad. Commented out some memory profiling stuff. svn path=/trunk/; revision=2811
-rw-r--r--camel/ChangeLog20
-rw-r--r--camel/camel-folder-summary.c19
-rw-r--r--camel/camel-mime-parser.c65
-rw-r--r--camel/camel-mime-part-utils.c1
-rw-r--r--camel/camel-mime-part.c1
-rw-r--r--camel/camel-mime-utils.c4
-rw-r--r--camel/providers/mbox/camel-mbox-summary.c12
7 files changed, 77 insertions, 45 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index ac81cd35cd..6515fadcb4 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,4 +1,22 @@
-2000-05-05 <notzed@the-dot-in.helixcode.com>
+2000-05-05 NotZed <NotZed@HelixCode.com>
+
+ * camel-folder-summary.c: And same here ...
+
+ * camel-mime-utils.c: Defined out some memory profiling stuff I
+ left there by mistake.
+
+ * camel-mime-parser.c (folder_scan_content): Apply the fix from
+ the header scanner to here too.
+ (folder_scan_header): Only check for end of header if we have
+ space for it (didn't end the read with a newline)
+ (folder_scan_header): inptr is the only real thing we need
+ registerised for performance. Try to help the compiler be smart
+ about it ..
+ (folder_scan_header): Simplified the save header case a tad.
+
+ Commented out some memory profiling stuff.
+
+2000-05-05 <notzed@helixcode.com>
* camel-mime-utils.c (header_decode_mailbox): Plug a memory leak.
(header_decode_text): Fixed memory leaks with g_string_append().
diff --git a/camel/camel-folder-summary.c b/camel/camel-folder-summary.c
index 6d8946ce12..0879d0fc37 100644
--- a/camel/camel-folder-summary.c
+++ b/camel/camel-folder-summary.c
@@ -35,7 +35,7 @@
#define d(x)
-#if 1
+#if 0
extern int strdup_count, malloc_count, free_count;
#endif
@@ -862,10 +862,6 @@ content_info_load(CamelFolderSummary *s, FILE *in)
ci = g_malloc0(s->content_info_size);
-/* bs->pos = decode_int(in);
- bs->bodypos = bs->pos + decode_int(in);
- bs->endpos = bs->pos + decode_int(in);*/
-
camel_folder_summary_decode_token(in, &type);
camel_folder_summary_decode_token(in, &subtype);
ct = header_content_type_new(type, subtype);
@@ -897,10 +893,6 @@ content_info_save(CamelFolderSummary *s, FILE *out, CamelMessageContentInfo *ci)
struct _header_content_type *ct;
struct _header_param *hp;
-/* camel_folder_summary_encode_uint32(out, bs->pos);
- camel_folder_summary_encode_uint32(out, bs->bodypos - bs->pos);
- camel_folder_summary_encode_uint32(out, bs->endpos - bs->pos);*/
-
ct = ci->type;
if (ct) {
camel_folder_summary_encode_token(out, ct->type);
@@ -1053,6 +1045,8 @@ int main(int argc, char **argv)
CamelFolderSummary *s;
char *buffer;
int len;
+ extern int strdup_count, malloc_count, free_count;
+ ibex *index;
gtk_init(&argc, &argv);
@@ -1081,6 +1075,8 @@ int main(int argc, char **argv)
fd = open(argv[1], O_RDONLY);
+ index = ibex_open("index.ibex", O_CREAT|O_RDWR, 0600);
+
mp = camel_mime_parser_new();
camel_mime_parser_scan_from(mp, TRUE);
/* camel_mime_parser_set_header_regex(mp, "^(content-[^:]*|subject|from|to|date):");*/
@@ -1088,6 +1084,7 @@ int main(int argc, char **argv)
s = camel_folder_summary_new();
camel_folder_summary_set_build_content(s, TRUE);
+/* camel_folder_summary_set_index(s, index);*/
while (camel_mime_parser_step(mp, &buffer, &len) == HSCAN_FROM) {
/*printf("Parsing message ...\n");*/
@@ -1097,6 +1094,10 @@ int main(int argc, char **argv)
break;
}
}
+
+ gtk_object_unref(mp);
+ gtk_object_unref(s);
+
printf("summarised %d messages\n", camel_folder_summary_count(s));
#if 0
printf("g_strdup count = %d\n", strdup_count);
diff --git a/camel/camel-mime-parser.c b/camel/camel-mime-parser.c
index 73a1172adb..91b4f6cd6e 100644
--- a/camel/camel-mime-parser.c
+++ b/camel/camel-mime-parser.c
@@ -50,6 +50,7 @@
#define STRUCT_ALIGN 4
+#if 0
extern int strdup_count;
extern int malloc_count;
extern int free_count;
@@ -57,7 +58,7 @@ extern int free_count;
#define g_strdup(x) (strdup_count++, g_strdup(x))
#define g_malloc(x) (malloc_count++, g_malloc(x))
#define g_free(x) (free_count++, g_free(x))
-
+#endif
#ifdef MEMPOOL
typedef struct _MemPoolNode {
@@ -1027,7 +1028,8 @@ folder_scan_header(struct _header_scan_state *s, int *lastone)
int len;
struct _header_scan_stack *part, *overpart = s->parts;
struct _header_scan_stack *h;
- register char *inptr, *inend;
+ char *inend;
+ register char *inptr;
h(printf("scanning first bit\n"));
@@ -1056,11 +1058,12 @@ retry:
while ((len = folder_read(s))>0 && len >= s->atleast) { /* ensure we have at least enough room here */
inptr = s->inptr;
inend = s->inend-s->atleast;
- start = inptr;
while (inptr<=inend) {
/*printf(" '%.20s'\n", inptr);*/
+ start = inptr;
+
if (!s->midline
&& (part = folder_boundary_check(s, inptr, lastone))) {
if ((s->outptr>s->outbuf) || (inptr-start))
@@ -1074,8 +1077,10 @@ retry:
;
/* check against the real buffer end, not our 'atleast limited' end */
- if (inptr> s->inend) {
- inptr-=2;
+ /* also make sure we have at least 1 char lookahead, so even if we found a \n at
+ the end, well, make out we didn't, and re-scan it next pass */
+ if (inptr>=s->inend) {
+ inptr--;
s->midline = TRUE;
} else {
s->midline = FALSE;
@@ -1087,31 +1092,29 @@ retry:
s->outbuf[0], isprint(s->outbuf[0])?s->outbuf[0]:'.',
s->outbuf[1], isprint(s->outbuf[1])?s->outbuf[1]:'.'));
- if (!s->midline) {
- if (!(inptr[0] == ' ' || inptr[0] == '\t')) {
- if (s->outbuf[0] == '\n'
- || (s->outbuf[0] == '\r' && s->outbuf[1]=='\n')) {
- goto header_done;
- }
-
- /* we always have at least _1_ char here ... */
- if (s->outptr[-1] == '\n')
- s->outptr--;
- s->outptr[0] = 0;
-
- d(printf("header %.10s at %d\n", s->outbuf, s->header_start));
-
- header_raw_append_parse(&h->headers, s->outbuf, s->header_start);
+ if (!s->midline
+ && !(inptr[0] == ' ' || inptr[0] == '\t')) {
+ if (s->outbuf[0] == '\n'
+ || (s->outbuf[0] == '\r' && s->outbuf[1]=='\n')) {
+ goto header_done;
+ }
- if (inptr[0]=='\n'
- || (inptr[0] == '\r' && inptr[1]=='\n')) {
- inptr++;
- goto header_done;
- }
- s->outptr = s->outbuf;
- s->header_start = -1;
+ /* we always have at least _1_ char here ... */
+ if (s->outptr[-1] == '\n')
+ s->outptr--;
+ s->outptr[0] = 0;
+
+ d(printf("header %.10s at %d\n", s->outbuf, s->header_start));
+
+ header_raw_append_parse(&h->headers, s->outbuf, s->header_start);
+
+ if (inptr[0]=='\n'
+ || (inptr[0] == '\r' && inptr[1]=='\n')) {
+ inptr++;
+ goto header_done;
}
- start = inptr;
+ s->outptr = s->outbuf;
+ s->header_start = -1;
}
}
s->inptr = inptr;
@@ -1171,7 +1174,8 @@ static struct _header_scan_stack *
folder_scan_content(struct _header_scan_state *s, int *lastone, char **data, int *length)
{
int atleast = s->atleast;
- register char *inptr, *inend;
+ register char *inptr;
+ char *inend;
char *start;
int len;
struct _header_scan_stack *part, *overpart = s->parts;
@@ -1218,8 +1222,9 @@ retry:
/* goto the next line */
while ((*inptr++)!='\n')
;
+
/* check against the real buffer end, not our 'atleast limited' end */
- if (inptr>= s->inend) {
+ if (inptr> s->inend) {
inptr--;
s->midline = TRUE;
} else {
diff --git a/camel/camel-mime-part-utils.c b/camel/camel-mime-part-utils.c
index fa914be960..adbc62d305 100644
--- a/camel/camel-mime-part-utils.c
+++ b/camel/camel-mime-part-utils.c
@@ -23,7 +23,6 @@
*/
#include <config.h>
#include <string.h>
-#include <glib.h>
#include "gmime-content-field.h"
#include "string-utils.h"
#include "camel-mime-part-utils.h"
diff --git a/camel/camel-mime-part.c b/camel/camel-mime-part.c
index bb3abe7062..fa22cf9dcb 100644
--- a/camel/camel-mime-part.c
+++ b/camel/camel-mime-part.c
@@ -25,7 +25,6 @@
#include <config.h>
#include <string.h>
-#include <glib.h>
#include "camel-mime-part.h"
#include <stdio.h>
#include "gmime-content-field.h"
diff --git a/camel/camel-mime-utils.c b/camel/camel-mime-utils.c
index 5eb26a6385..22b252116b 100644
--- a/camel/camel-mime-utils.c
+++ b/camel/camel-mime-utils.c
@@ -38,6 +38,7 @@
#include "camel-mime-utils.h"
+#if 0
int strdup_count = 0;
int malloc_count = 0;
int free_count = 0;
@@ -45,9 +46,10 @@ int free_count = 0;
#define g_strdup(x) (strdup_count++, g_strdup(x))
#define g_malloc(x) (malloc_count++, g_malloc(x))
#define g_free(x) (free_count++, g_free(x))
+#endif
/* for all warnings ... */
-#define w(x)
+#define w(x) x
#define d(x)
#define d2(x)
diff --git a/camel/providers/mbox/camel-mbox-summary.c b/camel/providers/mbox/camel-mbox-summary.c
index 35b7945e49..fedd9f6411 100644
--- a/camel/providers/mbox/camel-mbox-summary.c
+++ b/camel/providers/mbox/camel-mbox-summary.c
@@ -1056,11 +1056,19 @@ int camel_mbox_summary_check(CamelMboxSummary *s)
static void camel_mbox_summary_add(CamelMboxSummary *s, CamelMboxMessageInfo *info)
{
+ CamelMboxMessageInfo *old;
+
+retry:
if (info->info.uid == NULL) {
info->info.uid = g_strdup_printf("%u", s->nextuid++);
}
- if (g_hash_table_lookup(s->message_uid, info->info.uid)) {
- g_error("Trying to insert message with clashing uid's");
+ if (( old = g_hash_table_lookup(s->message_uid, info->info.uid) )) {
+#warning do something fatal with a fatal error.
+ /* err, once i work out why it keeps getting called so often */
+ d(g_warning("Trying to insert message with clashing uid's new %s exist %s", info->info.uid, old->info.uid));
+ g_free(info->info.uid);
+ info->info.uid = NULL;
+ goto retry;
}
d(printf("adding %s\n", info->info.uid));
g_ptr_array_add(s->messages, info);