1141098Sdes/*-
2228690Sdes * Copyright (c) 2005-2011 Dag-Erling Sm��rgrav
3141098Sdes * All rights reserved.
4141098Sdes *
5141098Sdes * Redistribution and use in source and binary forms, with or without
6141098Sdes * modification, are permitted provided that the following conditions
7141098Sdes * are met:
8141098Sdes * 1. Redistributions of source code must retain the above copyright
9255376Sdes *    notice, this list of conditions and the following disclaimer.
10141098Sdes * 2. Redistributions in binary form must reproduce the above copyright
11141098Sdes *    notice, this list of conditions and the following disclaimer in the
12141098Sdes *    documentation and/or other materials provided with the distribution.
13141098Sdes * 3. The name of the author may not be used to endorse or promote products
14141098Sdes *    derived from this software without specific prior written permission.
15141098Sdes *
16141098Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17141098Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18141098Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19141098Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20141098Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21141098Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22141098Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23141098Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24141098Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25141098Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26141098Sdes *
27255376Sdes * $Id: openpam_free_envlist.c 648 2013-03-05 17:54:27Z des $
28141098Sdes */
29141098Sdes
30228690Sdes#ifdef HAVE_CONFIG_H
31228690Sdes# include "config.h"
32228690Sdes#endif
33228690Sdes
34141098Sdes#include <stdlib.h>
35141098Sdes
36141098Sdes#include <security/pam_appl.h>
37141098Sdes
38141098Sdes#include "openpam_impl.h"
39141098Sdes
40141098Sdes/*
41141098Sdes * OpenPAM extension
42141098Sdes *
43141098Sdes * Free an environment list
44141098Sdes */
45141098Sdes
46141098Sdesvoid
47141098Sdesopenpam_free_envlist(char **envlist)
48141098Sdes{
49141098Sdes	char **env;
50141098Sdes
51141098Sdes	ENTER();
52141098Sdes	if (envlist == NULL)
53141098Sdes		RETURNV();
54141098Sdes	for (env = envlist; *env != NULL; ++env)
55141098Sdes		FREE(*env);
56141098Sdes	FREE(envlist);
57141098Sdes	RETURNV();
58141098Sdes}
59141098Sdes
60141098Sdes/*
61141098Sdes * Error codes:
62141098Sdes */
63141098Sdes
64141098Sdes/**
65141098Sdes * The =openpam_free_envlist function is a convenience function which
66141098Sdes * frees all the environment variables in an environment list, and the
67141098Sdes * list itself.
68141098Sdes * It is suitable for freeing the return value from =pam_getenvlist.
69228690Sdes *
70228690Sdes * AUTHOR DES
71141098Sdes */
72