Introduce strophe_free_and_null()
Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
@@ -93,6 +93,13 @@ void *strophe_realloc(const xmpp_ctx_t *ctx, void *p, size_t size);
|
|||||||
char *strophe_strdup(const xmpp_ctx_t *ctx, const char *s);
|
char *strophe_strdup(const xmpp_ctx_t *ctx, const char *s);
|
||||||
char *strophe_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len);
|
char *strophe_strndup(const xmpp_ctx_t *ctx, const char *s, size_t len);
|
||||||
void strophe_free(const xmpp_ctx_t *ctx, void *p);
|
void strophe_free(const xmpp_ctx_t *ctx, void *p);
|
||||||
|
#define strophe_free_and_null(ctx, p) \
|
||||||
|
do { \
|
||||||
|
if (p) { \
|
||||||
|
strophe_free(ctx, (p)); \
|
||||||
|
(p) = NULL; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
/* wrappers for xmpp_log at specific levels */
|
/* wrappers for xmpp_log at specific levels */
|
||||||
void strophe_error(const xmpp_ctx_t *ctx,
|
void strophe_error(const xmpp_ctx_t *ctx,
|
||||||
|
|||||||
18
src/conn.c
18
src/conn.c
@@ -1804,21 +1804,13 @@ static void _conn_reset(xmpp_conn_t *conn)
|
|||||||
|
|
||||||
if (conn->stream_error) {
|
if (conn->stream_error) {
|
||||||
xmpp_stanza_release(conn->stream_error->stanza);
|
xmpp_stanza_release(conn->stream_error->stanza);
|
||||||
if (conn->stream_error->text)
|
strophe_free_and_null(ctx, conn->stream_error->text);
|
||||||
strophe_free(ctx, conn->stream_error->text);
|
strophe_free_and_null(ctx, conn->stream_error);
|
||||||
strophe_free(ctx, conn->stream_error);
|
|
||||||
conn->stream_error = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conn->domain)
|
strophe_free_and_null(ctx, conn->domain);
|
||||||
strophe_free(ctx, conn->domain);
|
strophe_free_and_null(ctx, conn->bound_jid);
|
||||||
if (conn->bound_jid)
|
strophe_free_and_null(ctx, conn->stream_id);
|
||||||
strophe_free(ctx, conn->bound_jid);
|
|
||||||
if (conn->stream_id)
|
|
||||||
strophe_free(ctx, conn->stream_id);
|
|
||||||
conn->domain = NULL;
|
|
||||||
conn->bound_jid = NULL;
|
|
||||||
conn->stream_id = NULL;
|
|
||||||
conn->authenticated = 0;
|
conn->authenticated = 0;
|
||||||
conn->secured = 0;
|
conn->secured = 0;
|
||||||
conn->tls_failed = 0;
|
conn->tls_failed = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user