aboutsummaryrefslogtreecommitdiffstats
path: root/g10/packet.h
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-03-29 09:57:40 +0000
committerWerner Koch <[email protected]>2017-03-29 10:08:31 +0000
commitafa86809087909a8ba2f9356588bf90cc923529c (patch)
treeff0941a7831c23a47f9dafa522b375b7cc00daa4 /g10/packet.h
parentindent: Re-indent function free-packet. (diff)
downloadgnupg-afa86809087909a8ba2f9356588bf90cc923529c.tar.gz
gnupg-afa86809087909a8ba2f9356588bf90cc923529c.zip
gpg: Extend free_packet to handle a packet parser context.
* g10/packet.h (struct parse_packet_ctx_s): Add fields LAST_PKT and FREE_LAST_PKT. (init_parse_packet): Clear them. (deinit_parse_packet): New macro. Change all users if init_parse_packet to also call this macro. * g10/free-packet.c (free_packet): Add arg PARSECTX and handle shallow packet copies in the context. Change all callers. * g10/parse-packet.c (parse): Store certain packets in the parse context. -- Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g10/packet.h')
-rw-r--r--g10/packet.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/g10/packet.h b/g10/packet.h
index ffa1fe9d3..ad6f317e7 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -596,13 +596,22 @@ int set_packet_list_mode( int mode );
/* A context used with parse_packet. */
struct parse_packet_ctx_s
{
- iobuf_t inp; /* The input stream with the packets. */
+ iobuf_t inp; /* The input stream with the packets. */
+ PACKET *last_pkt; /* The last parsed packet. */
+ int free_last_pkt; /* Indicates that LAST_PKT must be freed. */
};
typedef struct parse_packet_ctx_s *parse_packet_ctx_t;
-#define init_parse_packet(a,i) do { (a)->inp = (i); \
- /**/ } while (0)
+#define init_parse_packet(a,i) do { \
+ (a)->inp = (i); \
+ (a)->last_pkt = NULL; \
+ (a)->free_last_pkt = 0; \
+ } while (0)
+#define deinit_parse_packet(a) do { \
+ if ((a)->free_last_pkt) \
+ free_packet (NULL, (a)); \
+ } while (0)
#if DEBUG_PARSE_PACKET
@@ -803,7 +812,7 @@ void free_public_key( PKT_public_key *key );
void free_attributes(PKT_user_id *uid);
void free_user_id( PKT_user_id *uid );
void free_comment( PKT_comment *rem );
-void free_packet( PACKET *pkt );
+void free_packet (PACKET *pkt, parse_packet_ctx_t parsectx);
prefitem_t *copy_prefs (const prefitem_t *prefs);
PKT_public_key *copy_public_key( PKT_public_key *d, PKT_public_key *s );
PKT_signature *copy_signature( PKT_signature *d, PKT_signature *s );