Welcome to mirror list, hosted at ThFree Co, Russian Federation.

wordfree.c « posix « libc « newlib - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 024a619d99130659579420180ae945df9f13751f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* 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>

#include <wordexp.h>
#include "wordexp2.h"

void
wordfree(wordexp_t *pwordexp)
{
  ext_wordv_t *wordv;

  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);
  }

  free(wordv);
  pwordexp->we_wordv = NULL;
}

#endif /* !_NO_WORDEXP  */