aboutsummaryrefslogtreecommitdiffstats
path: root/src/apoint.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-06-29 11:23:11 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-07-06 01:54:09 +0200
commita1394e98330eaaae67eb1567013d27ae1a25b77f (patch)
treecc0030855f678340dbaabb807d4c4a4c58961d46 /src/apoint.c
parent1c53c9d8c369d228c0fd0314b9915d218b5f5dca (diff)
downloadcalcurse-a1394e98330eaaae67eb1567013d27ae1a25b77f.tar.gz
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/apoint.c')
-rw-r--r--src/apoint.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/apoint.c b/src/apoint.c
index 57223bc..694c318 100644
--- a/src/apoint.c
+++ b/src/apoint.c
@@ -51,16 +51,21 @@ void apoint_free(struct apoint *apt)
mem_free(apt);
}
-static void apoint_dup(struct apoint *in, struct apoint *bkp)
+struct apoint *apoint_dup(struct apoint *in)
{
- EXIT_IF(!in || !bkp, _("null pointer"));
+ EXIT_IF(!in, _("null pointer"));
- bkp->start = in->start;
- bkp->dur = in->dur;
- bkp->state = in->state;
- bkp->mesg = mem_strdup(in->mesg);
+ struct apoint *apt = mem_malloc(sizeof(struct apoint));
+ apt->start = in->start;
+ apt->dur = in->dur;
+ apt->state = in->state;
+ apt->mesg = mem_strdup(in->mesg);
if (in->note)
- bkp->note = mem_strdup(in->note);
+ apt->note = mem_strdup(in->note);
+ else
+ apt->note = NULL;
+
+ return apt;
}
void apoint_llist_init(void)