diff options
author | markus@openbsd.org <markus@openbsd.org> | 2021-02-15 20:36:35 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2021-02-17 15:03:41 +1100 |
commit | b696858a7f9db72a83d02cb6edaca4b30a91b386 (patch) | |
tree | f0bf105679bef76edd4d6569d3357cab1ee4b42c /misc.c | |
parent | ad74fc127cc45567e170e8c6dfa2cfd9767324ec (diff) | |
download | openssh-git-b696858a7f9db72a83d02cb6edaca4b30a91b386.tar.gz |
upstream: factor out opt_array_append; ok djm@
OpenBSD-Commit-ID: 571bc5dd35f99c5cf9de6aaeac428b168218e74a
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.160 2021/01/15 02:58:11 dtucker Exp $ */ +/* $OpenBSD: misc.c,v 1.161 2021/02/15 20:36:35 markus Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -2439,6 +2439,32 @@ opt_match(const char **opts, const char *term) return 0; } +void +opt_array_append2(const char *file, const int line, const char *directive, + char ***array, int **iarray, u_int *lp, const char *s, int i) +{ + + if (*lp >= INT_MAX) + fatal("%s line %d: Too many %s entries", file, line, directive); + + if (iarray != NULL) { + *iarray = xrecallocarray(*iarray, *lp, *lp + 1, + sizeof(**iarray)); + (*iarray)[*lp] = i; + } + + *array = xrecallocarray(*array, *lp, *lp + 1, sizeof(**array)); + (*array)[*lp] = xstrdup(s); + (*lp)++; +} + +void +opt_array_append(const char *file, const int line, const char *directive, + char ***array, u_int *lp, const char *s) +{ + opt_array_append2(file, line, directive, array, NULL, lp, s, 0); +} + sshsig_t ssh_signal(int signum, sshsig_t handler) { |