aboutsummaryrefslogtreecommitdiffstats
path: root/trailer.h
diff options
context:
space:
mode:
authorLinus Arver <linus@ucla.edu>2024-05-02 04:54:23 +0000
committerJunio C Hamano <gitster@pobox.com>2024-05-02 09:57:08 -0700
commit24a25c630cfe72d2d77fed5d2841f7c017a269b5 (patch)
treefa702385e59e1e4235fc9abe509efbb7c6a96417 /trailer.h
parent655eb65d48bec60d24baf66bf19de394eb2e6aea (diff)
downloadgit-24a25c630cfe72d2d77fed5d2841f7c017a269b5.tar.gz
trailer: make parse_trailers() return trailer_info pointer
This is the second and final preparatory commit for making the trailer_info struct private to the trailer implementation. Make trailer_info_get() do the actual work of allocating a new trailer_info struct, and return a pointer to it. Because parse_trailers() wraps around trailer_info_get(), it too can return this pointer to the caller. From the trailer API user's perspective, the call to trailer_info_new() can be replaced with parse_trailers(); do so in interpret-trailers. Because trailer_info_new() is no longer called by interpret-trailers, remove this function from the trailer API. With this change, we no longer allocate trailer_info on the stack --- all uses of it are via a pointer where the actual data is always allocated at runtime through trailer_info_new(). Make trailer_info_release() free this dynamically allocated memory. Finally, due to the way the function signatures of parse_trailers() and trailer_info_get() have changed, update the callsites in format_trailers_from_commit() and trailer_iterator_init() accordingly. Helped-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Linus Arver <linus@ucla.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'trailer.h')
-rw-r--r--trailer.h17
1 files changed, 7 insertions, 10 deletions
diff --git a/trailer.h b/trailer.h
index 9ba9672139..c8c0018c54 100644
--- a/trailer.h
+++ b/trailer.h
@@ -89,18 +89,15 @@ void parse_trailers_from_command_line_args(struct list_head *arg_head,
void process_trailers_lists(struct list_head *head,
struct list_head *arg_head);
-void parse_trailers(const struct process_trailer_options *,
- struct trailer_info *,
- const char *str,
- struct list_head *head);
-
-void trailer_info_get(const struct process_trailer_options *,
- const char *str,
- struct trailer_info *);
+struct trailer_info *parse_trailers(const struct process_trailer_options *,
+ const char *str,
+ struct list_head *head);
+struct trailer_info *trailer_info_get(const struct process_trailer_options *,
+ const char *str);
+
size_t trailer_block_start(struct trailer_info *);
size_t trailer_block_end(struct trailer_info *);
int blank_line_before_trailer_block(struct trailer_info *);
-struct trailer_info *trailer_info_new(void);
void trailer_info_release(struct trailer_info *info);
@@ -141,7 +138,7 @@ struct trailer_iterator {
/* private */
struct {
- struct trailer_info info;
+ struct trailer_info *info;
size_t cur;
} internal;
};