18dffb485Schristos /* Frees the dynamically allocated storage from an earlier call to glob. 2*4b169a6bSchristos Copyright (C) 2017-2022 Free Software Foundation, Inc. 38dffb485Schristos This file is part of the GNU C Library. 48dffb485Schristos 58dffb485Schristos The GNU C Library is free software; you can redistribute it and/or 6*4b169a6bSchristos modify it under the terms of the GNU Lesser General Public 78dffb485Schristos License as published by the Free Software Foundation; either 8*4b169a6bSchristos version 2.1 of the License, or (at your option) any later version. 98dffb485Schristos 108dffb485Schristos The GNU C Library is distributed in the hope that it will be useful, 118dffb485Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 128dffb485Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13*4b169a6bSchristos Lesser General Public License for more details. 148dffb485Schristos 15*4b169a6bSchristos You should have received a copy of the GNU Lesser General Public 168dffb485Schristos License along with the GNU C Library; if not, see 178dffb485Schristos <https://www.gnu.org/licenses/>. */ 188dffb485Schristos 198dffb485Schristos #ifndef _LIBC 208dffb485Schristos # include <libc-config.h> 218dffb485Schristos #endif 228dffb485Schristos 238dffb485Schristos #include <glob.h> 248dffb485Schristos #include <stdlib.h> 258dffb485Schristos 268dffb485Schristos /* Free storage allocated in PGLOB by a previous `glob' call. */ 278dffb485Schristos void globfree(glob_t * pglob)288dffb485Schristosglobfree (glob_t *pglob) 298dffb485Schristos { 308dffb485Schristos if (pglob->gl_pathv != NULL) 318dffb485Schristos { 328dffb485Schristos size_t i; 338dffb485Schristos for (i = 0; i < pglob->gl_pathc; ++i) 348dffb485Schristos free (pglob->gl_pathv[pglob->gl_offs + i]); 358dffb485Schristos free (pglob->gl_pathv); 368dffb485Schristos pglob->gl_pathv = NULL; 378dffb485Schristos } 388dffb485Schristos } 398dffb485Schristos #ifndef globfree 408dffb485Schristos libc_hidden_def (globfree) 418dffb485Schristos #endif 42