ppp: implement ppp_packet_new()
PATCH 1/1 ppp: implement ppp_packet_new()
Centralize allocation of PPP packets.
--- gatchat/gatppp.c | 8 ++++++++ gatchat/ppp.h | 1 + gatchat/ppp_auth.c | 2 +- gatchat/ppp_cp.c | 2 +- 4 files changed, 11 insertions(+), 2 deletions(-)
gatchat/gatppp.c +8 -0
@@ -84,6 +84,14 @@ void ppp_debug(GAtPPP *ppp, const char *str) ppp->debugf (str, ppp->debug_data); } +struct ppp_header *ppp_packet_new (gsize infolen) +{ +struct ppp_header *ppp_packet; + + ppp_packet =g_try_malloc0 (infolen +sizeof (*ppp_packet)); +return ppp_packet; +} +/* * Silently discard packets which are received when they shouldn't be */
gatchat/ppp.h +1 -0
@@ -114,3 +114,4 @@ void ppp_lcp_finished_notify(GAtPPP *ppp);void ppp_set_recv_accm (GAtPPP *ppp,guint32 accm);void ppp_set_xmit_accm (GAtPPP *ppp,guint32 accm);void ppp_set_mtu (GAtPPP *ppp,const guint8 *data); +struct ppp_header *ppp_packet_new (gsize infolen);
gatchat/ppp_auth.c +1 -1
@@ -83,7 +83,7 @@ static void chap_process_challenge(struct ppp_chap *chap, const guint8 *packet)*/ digest_len =g_checksum_type_get_length (chap->method); response_length = digest_len +sizeof (*header) +1 ; - ppp_packet =g_try_malloc0 (response_length +sizeof (struct ppp_header )); + ppp_packet =ppp_packet_new (response_length);if (!ppp_packet) goto challenge_out;
gatchat/ppp_cp.c +1 -1
@@ -204,7 +204,7 @@ static struct pppcp_packet *pppcp_packet_new(struct pppcp_data *data,struct ppp_header *ppp_packet;guint16 packet_length = bufferlen +sizeof (*packet); - ppp_packet =g_try_malloc0 (packet_length +sizeof (*ppp_packet)); + ppp_packet =ppp_packet_new (packet_length);if (!ppp_packet)return NULL ;
Signature · 1 line
1.6.6.1