From c85c591ec970dac71cc0aef14b6eef589e40075a Mon Sep 17 00:00:00 2001 From: niki Date: Thu, 8 Dec 2005 21:56:41 +0000 Subject: [PATCH] missing in the repository since some time ... --- src/quota_common.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/quota_common.c diff --git a/src/quota_common.c b/src/quota_common.c new file mode 100644 index 00000000..7d507426 --- /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 +**/ + +#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); + } +} + -- 2.30.2