]> Pileus Git - lackey/blobdiff - src/util.c
Add size function, update ical/week
[lackey] / src / util.c
index 53f5cef71f691aa6b7ad3be9bd43520f9a609328..f13ad443c5f560418e5a30f4e27d4ad09abcebea 100644 (file)
@@ -1,4 +1,5 @@
 /*
+#include <string.h>
  * Copyright (C) 2012 Andy Spencer <andy753421@gmail.com>
  * 
  * This program is free software: you can redistribute it and/or modify
@@ -16,6 +17,8 @@
  */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include <ncurses.h>
 
 #include "screen.h"
@@ -29,6 +32,17 @@ void util_init(void)
        debug_fd = fopen("/tmp/lackey.log", "w+");
 }
 
+/* Misc functions */
+char *sdup(const char *str)
+{
+       if (str == NULL)
+               return NULL;
+       int len = strlen(str);
+       char *dup = malloc(len+1);
+       memcpy(dup, str, len+1);
+       return dup;
+}
+
 /* Debugging functions */
 int debug(char *fmt, ...)
 {