summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1baf5e2)
raw | patch | inline | side by side (parent: 1baf5e2)
author | niki <niki> | |
Thu, 8 Dec 2005 21:56:41 +0000 (21:56 +0000) | ||
committer | niki <niki> | |
Thu, 8 Dec 2005 21:56:41 +0000 (21:56 +0000) |
src/quota_common.c | [new file with mode: 0644] | patch | blob |
diff --git a/src/quota_common.c b/src/quota_common.c
--- /dev/null
+++ b/src/quota_common.c
@@ -0,0 +1,64 @@
+/**
+ * collectd - src/quota_common.c
+ * Copyright (C) 2005 Niki W. Waibel
+ *
+ * This program is free software; you can redistribute it and/
+ * or modify it under the terms of the GNU General Public Li-
+ * cence as published by the Free Software Foundation; either
+ * version 2 of the Licence, or any later version.
+ *
+ * This program is distributed in the hope that it will be use-
+ * ful, but WITHOUT ANY WARRANTY; without even the implied war-
+ * ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public Licence for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * Licence along with this program; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
+ * USA.
+ *
+ * Author:
+ * Niki W. Waibel <niki.waibel@gmx.net>
+**/
+
+#include "common.h"
+#include "quota_debug.h"
+#include "quota_common.h"
+
+void
+sstrncpy(char *d, const char *s, int len)
+{
+ strncpy(d, s, len);
+ d[len - 1] = 0;
+}
+
+char *
+sstrdup(const char *s)
+{
+ char *r = strdup(s);
+ if(r == NULL) {
+ DBG("Not enough memory.");
+ exit(3);
+ }
+ return r;
+}
+
+void *
+smalloc(size_t size)
+{
+ void *r = malloc(size);
+ if(r == NULL) {
+ DBG("Not enough memory.");
+ exit(3);
+ }
+ return r;
+}
+
+void
+sfree(void *ptr)
+{
+ if(ptr != NULL) {
+ free(ptr);
+ }
+}
+