aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-06-15 21:36:34 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-06-15 21:36:34 +0800
commit76f1b233865609c008e320a7e037be8cf64b48b7 (patch)
tree017e26f65a2597809c14e3b1b3dd2ec73e380040
parent4446fafb69e60a99df4c7b2f3788e6df5f24d778 (diff)
downloadgsoc2013-evolution-76f1b233865609c008e320a7e037be8cf64b48b7.tar.gz
gsoc2013-evolution-76f1b233865609c008e320a7e037be8cf64b48b7.tar.zst
gsoc2013-evolution-76f1b233865609c008e320a7e037be8cf64b48b7.zip
Init have_unget to FALSE. Don't set unget to NULL, it's no longer a
2004-06-15 Jeffrey Stedfast <fejj@ximian.com> * providers/imap4/camel-imap4-stream.c (camel_imap4_stream_init): Init have_unget to FALSE. Don't set unget to NULL, it's no longer a pointer. (camel_imap4_stream_finalize): No need to g_free() unget anymore. (camel_imap4_stream_next_token): Check have_unget rather than unget != NULL. Set have_unget to FALSE if we get an unget'd token. (camel_imap4_stream_unget_token): Don't malloc space for an unget token. The unget token is no longer a pointer. svn path=/trunk/; revision=26346
-rw-r--r--camel/ChangeLog11
-rw-r--r--camel/providers/imap4/camel-imap4-stream.c19
-rw-r--r--camel/providers/imap4/camel-imap4-stream.h3
3 files changed, 20 insertions, 13 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 52468b21d8..3abe96ac18 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,14 @@
+2004-06-15 Jeffrey Stedfast <fejj@ximian.com>
+
+ * providers/imap4/camel-imap4-stream.c (camel_imap4_stream_init):
+ Init have_unget to FALSE. Don't set unget to NULL, it's no longer
+ a pointer.
+ (camel_imap4_stream_finalize): No need to g_free() unget anymore.
+ (camel_imap4_stream_next_token): Check have_unget rather than
+ unget != NULL. Set have_unget to FALSE if we get an unget'd token.
+ (camel_imap4_stream_unget_token): Don't malloc space for an unget
+ token. The unget token is no longer a pointer.
+
2004-06-14 Not Zed <NotZed@Ximian.com>
* providers/smtp/camel-smtp-transport.c (smtp_data): use
diff --git a/camel/providers/imap4/camel-imap4-stream.c b/camel/providers/imap4/camel-imap4-stream.c
index de14f4e4ef..24a8285a79 100644
--- a/camel/providers/imap4/camel-imap4-stream.c
+++ b/camel/providers/imap4/camel-imap4-stream.c
@@ -91,6 +91,7 @@ camel_imap4_stream_init (CamelIMAP4Stream *imap4, CamelIMAP4StreamClass *klass)
imap4->mode = CAMEL_IMAP4_STREAM_MODE_TOKEN;
imap4->disconnected = FALSE;
+ imap4->have_unget = FALSE;
imap4->eol = FALSE;
imap4->literal = 0;
@@ -102,8 +103,6 @@ camel_imap4_stream_init (CamelIMAP4Stream *imap4, CamelIMAP4StreamClass *klass)
imap4->tokenbuf = g_malloc (IMAP4_TOKEN_LEN);
imap4->tokenptr = imap4->tokenbuf;
imap4->tokenleft = IMAP4_TOKEN_LEN;
-
- imap4->unget = NULL;
}
static void
@@ -115,7 +114,6 @@ camel_imap4_stream_finalize (CamelObject *object)
camel_object_unref (imap4->stream);
g_free (imap4->tokenbuf);
- g_free (imap4->unget);
}
@@ -340,10 +338,9 @@ camel_imap4_stream_next_token (CamelIMAP4Stream *stream, camel_imap4_token_t *to
g_return_val_if_fail (stream->mode != CAMEL_IMAP4_STREAM_MODE_LITERAL, -1);
g_return_val_if_fail (token != NULL, -1);
- if (stream->unget) {
- memcpy (token, stream->unget, sizeof (camel_imap4_token_t));
- g_free (stream->unget);
- stream->unget = NULL;
+ if (stream->have_unget) {
+ memcpy (token, &stream->unget, sizeof (camel_imap4_token_t));
+ stream->have_unget = FALSE;
return 0;
}
@@ -594,14 +591,12 @@ camel_imap4_stream_next_token (CamelIMAP4Stream *stream, camel_imap4_token_t *to
int
camel_imap4_stream_unget_token (CamelIMAP4Stream *stream, camel_imap4_token_t *token)
{
- camel_imap4_token_t *unget;
-
- if (stream->unget)
+ if (stream->have_unget)
return -1;
if (token->token != CAMEL_IMAP4_TOKEN_NO_DATA) {
- stream->unget = unget = g_new (camel_imap4_token_t, 1);
- memcpy (unget, token, sizeof (camel_imap4_token_t));
+ memcpy (&stream->unget, token, sizeof (camel_imap4_token_t));
+ stream->have_unget = TRUE;
}
return 0;
diff --git a/camel/providers/imap4/camel-imap4-stream.h b/camel/providers/imap4/camel-imap4-stream.h
index 7ef8422008..c0f870a0bd 100644
--- a/camel/providers/imap4/camel-imap4-stream.h
+++ b/camel/providers/imap4/camel-imap4-stream.h
@@ -80,6 +80,7 @@ struct _CamelIMAP4Stream {
CamelStream *stream;
guint disconnected:1; /* disconnected state */
+ guint have_unget:1; /* have an unget token */
guint mode:1; /* TOKEN vs LITERAL */
guint eol:1; /* end-of-literal */
@@ -96,7 +97,7 @@ struct _CamelIMAP4Stream {
unsigned char *tokenptr;
unsigned int tokenleft;
- camel_imap4_token_t *unget;
+ camel_imap4_token_t unget;
};
struct _CamelIMAP4StreamClass {