conn: don't hardcode buffer size
Use sizeof instead of hardcoded size, so the buffer can be changed easily.
This commit is contained in:
@@ -756,10 +756,10 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
|||||||
char *bigbuf;
|
char *bigbuf;
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
len = xmpp_vsnprintf(buf, 1024, fmt, ap);
|
len = xmpp_vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (len >= 1024) {
|
if (len >= sizeof(buf)) {
|
||||||
/* we need more space for this data, so we allocate a big
|
/* we need more space for this data, so we allocate a big
|
||||||
* enough buffer and print to that */
|
* enough buffer and print to that */
|
||||||
len++; /* account for trailing \0 */
|
len++; /* account for trailing \0 */
|
||||||
@@ -780,7 +780,6 @@ void xmpp_send_raw_string(xmpp_conn_t * const conn,
|
|||||||
xmpp_free(conn->ctx, bigbuf);
|
xmpp_free(conn->ctx, bigbuf);
|
||||||
} else {
|
} else {
|
||||||
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
xmpp_debug(conn->ctx, "conn", "SENT: %s", buf);
|
||||||
|
|
||||||
xmpp_send_raw(conn, buf, len);
|
xmpp_send_raw(conn, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user