aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers
diff options
context:
space:
mode:
Diffstat (limited to 'camel/providers')
-rw-r--r--camel/providers/imap4/camel-imap4-stream.c19
-rw-r--r--camel/providers/imap4/camel-imap4-stream.h3
2 files changed, 9 insertions, 13 deletions
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 {