-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathentry.c
50 lines (39 loc) · 963 Bytes
/
entry.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
49
50
/*
* Copyright (C) 2017 Niko Rosvall <[email protected]>
*/
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "utils.h"
#include "entry.h"
/* Allocate and return a new entry containing data.
Called must free the return value.
*/
Entry_t *entry_new(const char *title, const char *user,
const char *url, const char *password,
const char *notes)
{
Entry_t *new = NULL;
new = tmalloc(sizeof(struct _entry));
new->title = strdup(title);
new->user = strdup(user);
new->url = strdup(url);
new->password = strdup(password);
new->notes = strdup(notes);
new->stamp = NULL;
return new;
}
void entry_free(Entry_t *entry)
{
if(!entry)
return;
free(entry->title);
free(entry->user);
free(entry->url);
free(entry->password);
free(entry->notes);
if(entry->stamp)
free(entry->stamp);
free(entry);
}