PATCH: util-env
Volker Lendecke
vl at samba.org
Thu Oct 13 08:12:07 UTC 2016
"Trever L. Adams" <trever at middleearth.sapphiresunday.org> writes:
> On 10/12/2016 01:08 PM, Volker Lendecke wrote:
> Yes. It does. I am sorry. I some how failed to install after compiling
> when doing my testing. This patch has been tested.
Reviewed-by: Volker Lendecke <vl at samba.org>
>
> Trever
>
>
> diff --git a/lib/util/strv.c b/lib/util/strv.c
> index 577cd4d..f9bb040 100644
> --- a/lib/util/strv.c
> +++ b/lib/util/strv.c
> @@ -155,3 +155,29 @@ void strv_delete(char **strv, char *entry)
>
> *strv = talloc_realloc(NULL, *strv, char, len - entry_len);
> }
> +
> +char * const *strv_to_env(TALLOC_CTX *mem_ctx, char *strv)
> +{
> + char **data;
> + char *next = NULL;
> + size_t i;
> + size_t count = strv_count(strv);
> +
> + if (strv == NULL) {
> + return NULL;
> + }
> +
> + data = talloc_array(mem_ctx, char *, count + 1);
> +
> + if (data == NULL) {
> + return NULL;
> + }
> +
> + for(i = 0; i < count; i++) {
> + next = strv_next(strv, next);
> + data[i] = next;
> + }
> + data[count] = NULL;
> +
> + return data;
> +}
> diff --git a/lib/util/strv.h b/lib/util/strv.h
> index a3fe7ab..398e8ea 100644
> --- a/lib/util/strv.h
> +++ b/lib/util/strv.h
> @@ -29,5 +29,6 @@ char *strv_next(char *strv, const char *entry);
> char *strv_find(char *strv, const char *entry);
> size_t strv_count(char *strv);
> void strv_delete(char **strv, char *entry);
> +char * const *strv_to_env(TALLOC_CTX *mem_ctx, char *strv);
>
> #endif
More information about the samba-technical
mailing list