-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().
#define d(x)
-#if 1
+#if 0
extern int strdup_count, malloc_count, free_count;
#endif
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);
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);
CamelFolderSummary *s;
char *buffer;
int len;
+ extern int strdup_count, malloc_count, free_count;
+ ibex *index;
gtk_init(&argc, &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):");*/
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");*/
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);
#define STRUCT_ALIGN 4
+#if 0
extern int strdup_count;
extern int malloc_count;
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 {
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"));
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))
;
/* 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;
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;
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;
/* 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 {
*/
#include <config.h>
#include <string.h>
-#include <glib.h>
#include "gmime-content-field.h"
#include "string-utils.h"
#include "camel-mime-part-utils.h"
#include <config.h>
#include <string.h>
-#include <glib.h>
#include "camel-mime-part.h"
#include <stdio.h>
#include "gmime-content-field.h"
#include "camel-mime-utils.h"
+#if 0
int strdup_count = 0;
int malloc_count = 0;
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)
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);