diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-06-29 11:23:11 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2012-07-06 01:54:09 +0200 |
commit | a1394e98330eaaae67eb1567013d27ae1a25b77f (patch) | |
tree | cc0030855f678340dbaabb807d4c4a4c58961d46 /src/event.c | |
parent | 1c53c9d8c369d228c0fd0314b9915d218b5f5dca (diff) | |
download | calcurse-a1394e98330eaaae67eb1567013d27ae1a25b77f.zip |
Refactor *_dup()
* Actually duplicate an item instead of copying data only.
* Properly clone an item without a note.
* Mark *_dup() public.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/event.c')
-rw-r--r-- | src/event.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/event.c b/src/event.c index aed504a..de0ce02 100644 --- a/src/event.c +++ b/src/event.c @@ -50,15 +50,20 @@ void event_free(struct event *ev) mem_free(ev); } -static void event_dup(struct event *in, struct event *bkp) +struct event *event_dup(struct event *in) { - EXIT_IF(!in || !bkp, _("null pointer")); + EXIT_IF(!in, _("null pointer")); - bkp->id = in->id; - bkp->day = in->day; - bkp->mesg = mem_strdup(in->mesg); + struct event *ev = mem_malloc(sizeof(struct event)); + ev->id = in->id; + ev->day = in->day; + ev->mesg = mem_strdup(in->mesg); if (in->note) - bkp->note = mem_strdup(in->note); + ev->note = mem_strdup(in->note); + else + ev->note = NULL; + + return ev; } void event_llist_init(void) |