gmime r1342 - in trunk: . docs/reference gmime
- From: fejj svn gnome org
- To: svn-commits-list gnome org
- Subject: gmime r1342 - in trunk: . docs/reference gmime
- Date: Sat, 7 Jun 2008 16:12:29 +0000 (UTC)
Author: fejj
Date: Sat Jun 7 16:12:29 2008
New Revision: 1342
URL: http://svn.gnome.org/viewvc/gmime?rev=1342&view=rev
Log:
2008-06-07 Jeffrey Stedfast <fejj novell com>
* gmime/gmime-parse-utils.c (g_mime_decode_word): No longer
returns a strdup'd string, this helps increase the performance of
the address parser and reduces memory fragmentation.
* gmime/gmime-utils.c (g_mime_references_decode): Updated for
decode_word() changes.
(decode_addrspec): Same.
* gmime/internet-address.c (decode_mailbox): Make sure we don't
stray beyond the end of the input string. Also updated for changes
to decode_word() (which now returns a const string rather than a
strdup'd string).
* gmime/gmime-header.c (g_mime_header_iter_is_valid): Fixed an FMR
when the header the cursor is pointing to has been removed by
validating the hdrlist version first.
Modified:
trunk/ChangeLog
trunk/docs/reference/gmime.hierarchy
trunk/gmime/gmime-header.c
trunk/gmime/gmime-parse-utils.c
trunk/gmime/gmime-parse-utils.h
trunk/gmime/gmime-utils.c
trunk/gmime/internet-address.c
Modified: trunk/docs/reference/gmime.hierarchy
==============================================================================
--- trunk/docs/reference/gmime.hierarchy (original)
+++ trunk/docs/reference/gmime.hierarchy Sat Jun 7 16:12:29 2008
@@ -36,3 +36,4 @@
GMimeStreamMmap
GMimeStreamNull
GInterface
+ GTypePlugin
Modified: trunk/gmime/gmime-header.c
==============================================================================
--- trunk/gmime/gmime-header.c (original)
+++ trunk/gmime/gmime-header.c Sat Jun 7 16:12:29 2008
@@ -235,10 +235,13 @@
{
g_return_val_if_fail (iter != NULL, FALSE);
- if (!iter->hdrlist || !iter->cursor || !iter->cursor->next)
+ if (!iter->hdrlist || iter->version != iter->hdrlist->version)
return FALSE;
- return iter->version == iter->hdrlist->version;
+ if (!iter->cursor || !iter->cursor->next)
+ return FALSE;
+
+ return TRUE;
}
Modified: trunk/gmime/gmime-parse-utils.c
==============================================================================
--- trunk/gmime/gmime-parse-utils.c (original)
+++ trunk/gmime/gmime-parse-utils.c Sat Jun 7 16:12:29 2008
@@ -74,15 +74,14 @@
*in = inptr;
}
-static char *
+static const char *
decode_quoted_string (const char **in)
{
- const char *inptr = *in;
- char *out = NULL;
+ register const char *inptr = *in;
+ const char *qstring = NULL;
- decode_lwsp (&inptr);
if (*inptr == '"') {
- out = (char *) inptr;
+ qstring = inptr;
inptr++;
while (*inptr && *inptr != '"') {
@@ -96,28 +95,28 @@
if (*inptr == '"')
inptr++;
- out = g_strndup (out, inptr - out);
+ *in = inptr;
}
- *in = inptr;
-
- return out;
+ return qstring;
}
-static char *
+static const char *
decode_atom (const char **in)
{
- const char *inptr = *in, *start;
+ register const char *inptr = *in;
+ const char *atom = NULL;
- decode_lwsp (&inptr);
- start = inptr;
+ if (!is_atom (*inptr))
+ return NULL;
+
+ atom = inptr++;
while (is_atom (*inptr))
inptr++;
+
*in = inptr;
- if (inptr > start)
- return g_strndup (start, inptr - start);
- else
- return NULL;
+
+ return atom;
}
@@ -129,7 +128,7 @@
*
* Returns: the next rfc822 'word' token or %NULL if non exist.
**/
-char *
+const char *
g_mime_decode_word (const char **in)
{
const char *inptr = *in;
@@ -200,9 +199,9 @@
char *
g_mime_decode_domain (const char **in)
{
- const char *inptr, *save;
+ const char *inptr, *save, *atom;
GString *domain;
- char *dom, *atom;
+ char *dom;
domain = g_string_new ("");
@@ -230,8 +229,7 @@
break;
}
- g_string_append (domain, atom);
- g_free (atom);
+ g_string_append_len (domain, atom, inptr - atom);
}
save = inptr;
Modified: trunk/gmime/gmime-parse-utils.h
==============================================================================
--- trunk/gmime/gmime-parse-utils.h (original)
+++ trunk/gmime/gmime-parse-utils.h Sat Jun 7 16:12:29 2008
@@ -27,7 +27,7 @@
void g_mime_decode_lwsp (const char **in);
#define decode_lwsp(in) g_mime_decode_lwsp (in)
-char *g_mime_decode_word (const char **in);
+const char *g_mime_decode_word (const char **in);
#define decode_word(in) g_mime_decode_word (in)
char *g_mime_decode_domain (const char **in);
Modified: trunk/gmime/gmime-utils.c
==============================================================================
--- trunk/gmime/gmime-utils.c (original)
+++ trunk/gmime/gmime-utils.c Sat Jun 7 16:12:29 2008
@@ -827,8 +827,8 @@
static char *
decode_addrspec (const char **in)
{
- char *domain, *word, *str = NULL;
- const char *inptr;
+ char *domain, *str = NULL;
+ const char *word, *inptr;
GString *addrspec;
decode_lwsp (in);
@@ -839,17 +839,16 @@
return NULL;
}
- addrspec = g_string_new (word);
- g_free (word);
+ addrspec = g_string_new ("");
+ g_string_append_len (addrspec, word, inptr - word);
/* get the rest of the local-part */
decode_lwsp (&inptr);
while (*inptr == '.') {
g_string_append_c (addrspec, *inptr++);
if ((word = decode_word (&inptr))) {
- g_string_append (addrspec, word);
+ g_string_append_len (addrspec, word, inptr - word);
decode_lwsp (&inptr);
- g_free (word);
} else {
w(g_warning ("Invalid local-part in addr-spec: %s", *in));
goto exception;
@@ -952,8 +951,8 @@
g_mime_references_decode (const char *text)
{
GMimeReferences *refs, *tail, *ref;
- const char *inptr = text;
- char *word, *msgid;
+ const char *word, *inptr = text;
+ char *msgid;
g_return_val_if_fail (text != NULL, NULL);
@@ -976,9 +975,7 @@
}
} else if (*inptr) {
/* looks like part of a phrase */
- if ((word = decode_word (&inptr))) {
- g_free (word);
- } else {
+ if (!(word = decode_word (&inptr))) {
w(g_warning ("Invalid References header: %s", inptr));
break;
}
Modified: trunk/gmime/internet-address.c
==============================================================================
--- trunk/gmime/internet-address.c (original)
+++ trunk/gmime/internet-address.c Sat Jun 7 16:12:29 2008
@@ -770,38 +770,42 @@
decode_mailbox (const char **in)
{
InternetAddress *mailbox = NULL;
- const char *inptr;
+ const char *inptr, *word;
gboolean bracket = FALSE;
GString *name = NULL;
GString *addr;
- char *pre;
+ size_t n = 0;
addr = g_string_new ("");
decode_lwsp (in);
inptr = *in;
- pre = decode_word (&inptr);
+ if ((word = decode_word (&inptr)))
+ n = inptr - word;
+
decode_lwsp (&inptr);
if (*inptr && !strchr (",.@", *inptr)) {
gboolean retried = FALSE;
/* this mailbox has a name part, so get the name */
name = g_string_new ("");
- while (pre) {
+ while (word) {
+ g_string_append_len (name, word, n);
retried = FALSE;
- g_string_append (name, pre);
- g_free (pre);
retry:
- if ((pre = decode_word (&inptr)))
+ if ((word = decode_word (&inptr))) {
g_string_append_c (name, ' ');
+ n = inptr - word;
+ }
}
decode_lwsp (&inptr);
if (*inptr == '<') {
inptr++;
bracket = TRUE;
- pre = decode_word (&inptr);
+ if ((word = decode_word (&inptr)))
+ n = inptr - word;
} else if (!retried && *inptr) {
w(g_warning ("Unexpected char '%c' in mailbox: %s: attempting recovery.",
*inptr, *in));
@@ -818,8 +822,8 @@
}
}
- if (pre) {
- g_string_append (addr, pre);
+ if (word) {
+ g_string_append_len (addr, word, n);
} else {
w(g_warning ("No local part for email address: %s", *in));
if (name)
@@ -827,7 +831,7 @@
g_string_free (addr, TRUE);
/* comma will be eaten by our caller */
- if (*inptr != ',')
+ if (*inptr && *inptr != ',')
*in = inptr + 1;
else
*in = inptr;
@@ -837,16 +841,16 @@
/* get the rest of the local-part */
decode_lwsp (&inptr);
- while (*inptr == '.' && pre) {
+ while (*inptr == '.' && word) {
inptr++;
- g_free (pre);
- if ((pre = decode_word (&inptr))) {
+
+ if ((word = decode_word (&inptr))) {
g_string_append_c (addr, '.');
- g_string_append (addr, pre);
+ g_string_append_len (addr, word, inptr - word);
}
+
decode_lwsp (&inptr);
}
- g_free (pre);
/* we should be at the '@' now... */
if (*inptr == '@') {
@@ -929,20 +933,19 @@
{
InternetAddress *addr = NULL;
const char *inptr, *start;
+ const char *word;
GString *name;
- char *pre;
decode_lwsp (in);
start = inptr = *in;
/* pre-scan */
name = g_string_new ("");
- pre = decode_word (&inptr);
- while (pre) {
- g_string_append (name, pre);
- g_free (pre);
-
- if ((pre = decode_word (&inptr)))
+ word = decode_word (&inptr);
+
+ while (word) {
+ g_string_append_len (name, word, inptr - word);
+ if ((word = decode_word (&inptr)))
g_string_append_c (name, ' ');
}
@@ -1024,7 +1027,6 @@
const char *start;
start = inptr;
-
addr = decode_address (&inptr);
if (addr) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]