mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
ba57f8302a
commit
afa8680908
12 changed files with 124 additions and 53 deletions
17
g10/packet.h
17
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 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue