Retro68/gcc/newlib/libc/posix/wordfree.c

49 lines
947 B
C
Raw Normal View History

2017-04-11 21:13:36 +00:00
/* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
*
* Permission to use, copy, modify, and distribute this software
* is freely granted, provided that this notice is preserved.
*/
#ifndef _NO_WORDEXP
#include <sys/param.h>
#include <sys/stat.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <glob.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/queue.h>
2017-04-11 21:13:36 +00:00
#include <wordexp.h>
#include "wordexp2.h"
2017-04-11 21:13:36 +00:00
void
wordfree(wordexp_t *pwordexp)
{
ext_wordv_t *wordv;
2017-04-11 21:13:36 +00:00
if (pwordexp == NULL)
return;
if (pwordexp->we_wordv == NULL)
return;
wordv = WE_WORDV_TO_EXT_WORDV(pwordexp->we_wordv);
while (!SLIST_EMPTY(&wordv->list)) {
struct ewords_entry *entry = SLIST_FIRST(&wordv->list);
SLIST_REMOVE_HEAD(&wordv->list, next);
free(entry);
}
2017-04-11 21:13:36 +00:00
free(wordv);
2017-04-11 21:13:36 +00:00
pwordexp->we_wordv = NULL;
}
#endif /* !_NO_WORDEXP */