summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-18 13:09:49 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-18 13:09:49 +0000
commit91d431dacd79d93d671ace690e2e9c7fbb0f2877 (patch)
tree40757240f65899615dfc4f6b1f8c7b2f47d4af48 /src/buffer.c
parent406e9ad8c741fe18b9f3722bed679c3dc4e96614 (diff)
Max Kellermann <max@duempel.org>:
Simplify logging infrastructure
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c76
1 files changed, 0 insertions, 76 deletions
diff --git a/src/buffer.c b/src/buffer.c
deleted file mode 100644
index 739174a..0000000
--- a/src/buffer.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * (C) 2006-2008 by Pablo Neira Ayuso <pablo@netfilter.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include "buffer.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-struct buffer *buffer_create(size_t size)
-{
- struct buffer *b;
-
- b = malloc(sizeof(struct buffer));
- if (b == NULL)
- return NULL;
- memset(b, 0, sizeof(struct buffer));
-
- b->size = size;
-
- b->data = malloc(size);
- if (b->data == NULL) {
- free(b);
- return NULL;
- }
- memset(b->data, 0, size);
-
- return b;
-}
-
-void buffer_destroy(struct buffer *b)
-{
- free(b->data);
- free(b);
-}
-
-int buffer_add(struct buffer *b, void *data, size_t size)
-{
- if (b->size - b->cur_size < size) {
- errno = ENOSPC;
- return -1;
- }
-
- memcpy(b->data + b->cur_size, data, size);
- b->cur_size += size;
- return 0;
-}
-
-void buffer_flush(struct buffer *b,
- void (*cb)(void *buffer_data, void *data),
- void *data)
-{
- cb(b->data, data);
- b->cur_size = 0;
- memset(b->data, 0, b->size);
-}
-
-size_t buffer_size(const struct buffer *b)
-{
- return b->size;
-}