File: copylist.c

package info (click to toggle)
icmake 6.22-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,120 kB
  • ctags: 1,045
  • sloc: ansic: 9,241; makefile: 1,138; asm: 126; sh: 124
file content (42 lines) | stat: -rw-r--r-- 956 bytes parent folder | download | duplicates (3)
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
/*
\funcref{copylist}{VAR\_ copylist (\params)}
    {
        {VAR\_} {v} {variable holding list to copy}
    }
    {variable with copied list}
    {xrealloc(), xstrdup()}
    {inlist(), addtolist()}
    {copylist.c}
    {
        This function copies the list of the variable which is stated as a
        parameter. A variable holding the copied list is returned.

        The type of the returned variable is set to {\em e\_list}, while the
        {\em e\_temp} flag is also set.
    }
*/

#include "icm-exec.h"

VAR_ copylist (v)
VAR_ v;
{
    register unsigned
        i;
    VAR_
        ret;
    LIST_
        *vlist,
        *rlist;

    ret = newvar (e_list);

    rlist = &(ret.vu.i->ls.list);
    vlist = &(v.vu.i->ls.list);
    rlist->size = vlist->size;
    rlist->element = xrealloc (NULL, (vlist->size * sizeof (char *)));
    for (i = 0; i < vlist->size; i++)
        rlist->element [i] = xstrdup (vlist->element [i]);

    return (ret);
}