1
0
mirror of https://github.com/git/git.git synced 2024-09-29 10:51:21 +02:00
git/argv-array.h
Jeff King eccb614924 use "sentinel" function attribute for variadic lists
This attribute can help gcc notice when callers forget to
add a NULL sentinel to the end of the function. This is our
first use of the sentinel attribute, but we shouldn't need
to #ifdef for other compilers, as __attribute__ is already a
no-op on non-gcc-compatible compilers.

Suggested-by: Bert Wesarg <bert.wesarg@googlemail.com>
More-Spots-Found-By: Matt Kraai <kraai@ftbfs.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-09 22:23:09 -07:00

26 lines
700 B
C

#ifndef ARGV_ARRAY_H
#define ARGV_ARRAY_H
extern const char *empty_argv[];
struct argv_array {
const char **argv;
int argc;
int alloc;
};
#define ARGV_ARRAY_INIT { empty_argv, 0, 0 }
void argv_array_init(struct argv_array *);
void argv_array_push(struct argv_array *, const char *);
__attribute__((format (printf,2,3)))
void argv_array_pushf(struct argv_array *, const char *fmt, ...);
__attribute__((sentinel))
void argv_array_pushl(struct argv_array *, ...);
void argv_array_pop(struct argv_array *);
void argv_array_clear(struct argv_array *);
const char **argv_array_detach(struct argv_array *array, int *argc);
void argv_array_free_detached(const char **argv);
#endif /* ARGV_ARRAY_H */