diff --git a/mpp/base/inc/mpp_packet_impl.h b/mpp/base/inc/mpp_packet_impl.h index 250bc584..0e85d191 100644 --- a/mpp/base/inc/mpp_packet_impl.h +++ b/mpp/base/inc/mpp_packet_impl.h @@ -51,6 +51,9 @@ typedef struct MppPacketImpl_t { MppMeta meta; } MppPacketImpl; +#ifdef __cplusplus +extern "C" { +#endif /* * mpp_packet_reset is only used internelly and should NOT be used outside */ @@ -59,4 +62,8 @@ MPP_RET mpp_packet_reset(MppPacketImpl *packet); /* pointer check function */ MPP_RET check_is_mpp_packet(void *ptr); +#ifdef __cplusplus +} +#endif + #endif /*__MPP_PACKET_IMPL_H__*/ diff --git a/mpp/base/mpp_packet.cpp b/mpp/base/mpp_packet.cpp index 00a78809..6cb59f58 100644 --- a/mpp/base/mpp_packet.cpp +++ b/mpp/base/mpp_packet.cpp @@ -255,7 +255,14 @@ MPP_RET mpp_packet_reset(MppPacketImpl *packet) if (check_is_mpp_packet(packet)) return MPP_ERR_UNKNOW; + void *data = packet->data; + size_t size = packet->size; + memset(packet, 0, sizeof(*packet)); + + packet->data = data; + packet->pos = data; + packet->size = size; setup_mpp_packet_name(packet); return MPP_OK; }