forked from miekg/rdup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.c
48 lines (43 loc) · 1.14 KB
/
common.c
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
/* common functions for entries */
#include <glib.h>
#include <sys/stat.h>
#include "entry.h"
struct rdup *
entry_dup(struct rdup *f)
{
struct rdup *g;
g = g_malloc(sizeof(struct rdup));
g->plusmin = f->plusmin;
if (f->f_name != NULL)
g->f_name = g_strdup(f->f_name);
else
g->f_name = NULL;
if (f->f_target != NULL)
g->f_target = g_strdup(f->f_target);
else
g->f_target = NULL;
g->f_name_size = f->f_name_size;
g->f_lnk = f->f_lnk;
g->f_uid = f->f_uid;
g->f_user = f->f_user;
g->f_gid = f->f_gid;
g->f_group = f->f_group;
g->f_mode = f->f_mode;
g->f_ctime = f->f_ctime;
g->f_mtime = f->f_mtime;
g->f_atime = f->f_atime;
g->f_size = f->f_size;
g->f_dev = f->f_dev;
g->f_rdev = f->f_rdev;
g->f_ino = f->f_ino;
return g;
}
void
entry_free(struct rdup *f)
{
if (f->f_name != NULL)
g_free(f->f_name);
if (f->f_target != NULL)
g_free(f->f_target);
g_free(f);
}