aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/README.wmem8
-rw-r--r--epan/CMakeLists.txt1
-rw-r--r--epan/wmem/Makefile.common2
-rw-r--r--epan/wmem/wmem.h1
-rw-r--r--epan/wmem/wmem_slab.c130
-rw-r--r--epan/wmem/wmem_slab.h70
-rw-r--r--epan/wmem/wmem_slist.c13
-rw-r--r--epan/wmem/wmem_stack.c1
-rwxr-xr-xtools/test-common.sh1
-rwxr-xr-xtools/valgrind-wireshark.sh1
10 files changed, 7 insertions, 221 deletions
diff --git a/doc/README.wmem b/doc/README.wmem
index 18de24a327..f8860d7071 100644
--- a/doc/README.wmem
+++ b/doc/README.wmem
@@ -107,13 +107,7 @@ to the lifetime of the pinfo struct.
- wmem_slist_frame_data
- wmem_slist_count
-2.6 Slab
-
- - wmem_slab_new
- - wmem_slab_alloc
- - wmem_slab_free
-
-2.7 String-Buffers
+2.6 String-Buffers
- wmem_strbuf_new
- wmem_strbuf_sized_new
diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt
index 98c0f11303..d46e5b50d8 100644
--- a/epan/CMakeLists.txt
+++ b/epan/CMakeLists.txt
@@ -1370,7 +1370,6 @@ set(WMEM_FILES
wmem/wmem_allocator_simple.c
wmem/wmem_allocator_strict.c
wmem/wmem_scopes.c
- wmem/wmem_slab.c
wmem/wmem_slist.c
wmem/wmem_stack.c
wmem/wmem_strbuf.c
diff --git a/epan/wmem/Makefile.common b/epan/wmem/Makefile.common
index ee29d22b1d..da9e6e5a51 100644
--- a/epan/wmem/Makefile.common
+++ b/epan/wmem/Makefile.common
@@ -29,7 +29,6 @@ LIBWMEM_SRC = \
wmem_allocator_simple.c \
wmem_allocator_strict.c \
wmem_scopes.c \
- wmem_slab.c \
wmem_slist.c \
wmem_stack.c \
wmem_strbuf.c \
@@ -43,7 +42,6 @@ LIBWMEM_INCLUDES = \
wmem_allocator_simple.h \
wmem_allocator_strict.h \
wmem_scopes.h \
- wmem_slab.h \
wmem_slist.h \
wmem_stack.h \
wmem_strbuf.h \
diff --git a/epan/wmem/wmem.h b/epan/wmem/wmem.h
index 7701a1c106..253eff8179 100644
--- a/epan/wmem/wmem.h
+++ b/epan/wmem/wmem.h
@@ -28,7 +28,6 @@
#include "wmem_core.h"
#include "wmem_scopes.h"
-#include "wmem_slab.h"
#include "wmem_slist.h"
#include "wmem_stack.h"
#include "wmem_strbuf.h"
diff --git a/epan/wmem/wmem_slab.c b/epan/wmem/wmem_slab.c
deleted file mode 100644
index 556fb66396..0000000000
--- a/epan/wmem/wmem_slab.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/* wmem_slab.c
- * Wireshark Memory Manager Slab Allocator
- * Copyright 2012, Evan Huus <eapache@gmail.com>
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <glib.h>
-
-#include "wmem_core.h"
-#include "wmem_slab.h"
-
-typedef struct _wmem_slab_chunk_t {
- struct _wmem_slab_chunk_t *next;
-} wmem_slab_chunk_t;
-
-struct _wmem_slab_t {
- gboolean debug;
- size_t chunk_size;
- wmem_slab_chunk_t *free_list;
-
- wmem_allocator_t *allocator;
-};
-
-/* arbitrary, nice power-of-two value */
-#define WMEM_CHUNKS_PER_ALLOC 8
-
-static void
-wmem_slab_alloc_chunks(wmem_slab_t *slab)
-{
- guint i;
- guint8 *chunks;
- wmem_slab_chunk_t *chunk;
-
- /* We use a guint8 so that all the necessary pointer arithmetic is easy */
- chunks = (guint8*) wmem_alloc(slab->allocator,
- slab->chunk_size * WMEM_CHUNKS_PER_ALLOC);
-
- /* Now pick each chunk out of the allocated block and add it to the
- * slab's free_list */
- for (i=0; i<WMEM_CHUNKS_PER_ALLOC; i++) {
- chunk = (wmem_slab_chunk_t *) (chunks + (i * slab->chunk_size));
- chunk->next = slab->free_list;
- slab->free_list = chunk;
- }
-}
-
-void *
-wmem_slab_alloc(wmem_slab_t *slab)
-{
- wmem_slab_chunk_t *chunk;
-
- if (slab->debug) {
- return wmem_alloc(slab->allocator, slab->chunk_size);
- }
-
- if (slab->free_list == NULL) {
- wmem_slab_alloc_chunks(slab);
- }
-
- chunk = slab->free_list;
- slab->free_list = chunk->next;
-
- return (void *) chunk;
-}
-
-void
-wmem_slab_free(wmem_slab_t *slab, void *object)
-{
- wmem_slab_chunk_t *chunk;
- chunk = (wmem_slab_chunk_t *) object;
-
- if (slab->debug) {
- wmem_free(slab->allocator, chunk);
- return;
- }
-
- chunk->next = slab->free_list;
- slab->free_list = chunk;
-}
-
-wmem_slab_t *
-wmem_slab_new(wmem_allocator_t *allocator, const size_t chunk_size)
-{
- wmem_slab_t *slab;
-
- slab = wmem_alloc(allocator, sizeof(wmem_slab_t));
-
- slab->chunk_size = (chunk_size > sizeof(wmem_slab_chunk_t)) ?
- chunk_size :
- sizeof(wmem_slab_chunk_t);
- slab->free_list = NULL;
- slab->allocator = allocator;
- slab->debug = getenv("WIRESHARK_DEBUG_WMEM_SLAB") ? TRUE : FALSE;
-
- return slab;
-}
-
-/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
- *
- * Local variables:
- * c-basic-offset: 4
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * vi: set shiftwidth=4 tabstop=8 expandtab:
- * :indentSize=4:tabSize=8:noTabs=true:
- */
diff --git a/epan/wmem/wmem_slab.h b/epan/wmem/wmem_slab.h
deleted file mode 100644
index 1cd032ae17..0000000000
--- a/epan/wmem/wmem_slab.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* wmem_slab.h
- * Definitions for the Wireshark Memory Manager Slab
- * Copyright 2012, Evan Huus <eapache@gmail.com>
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef __WMEM_SLAB_H__
-#define __WMEM_SLAB_H__
-
-#include <string.h>
-
-#include "wmem_core.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-struct _wmem_slab_t;
-
-typedef struct _wmem_slab_t wmem_slab_t;
-
-WS_DLL_PUBLIC
-void *
-wmem_slab_alloc(wmem_slab_t *slab);
-
-WS_DLL_PUBLIC
-void
-wmem_slab_free(wmem_slab_t *slab, void *object);
-
-WS_DLL_PUBLIC
-wmem_slab_t *
-wmem_slab_new(wmem_allocator_t *allocator, const size_t chunk_size);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __WMEM_SLAB_H__ */
-
-/*
- * Editor modelines - http://www.wireshark.org/tools/modelines.html
- *
- * Local variables:
- * c-basic-offset: 4
- * tab-width: 8
- * indent-tabs-mode: nil
- * End:
- *
- * vi: set shiftwidth=4 tabstop=8 expandtab:
- * :indentSize=4:tabSize=8:noTabs=true:
- */
diff --git a/epan/wmem/wmem_slist.c b/epan/wmem/wmem_slist.c
index e4cd15d042..d4341359f2 100644
--- a/epan/wmem/wmem_slist.c
+++ b/epan/wmem/wmem_slist.c
@@ -27,7 +27,6 @@
#include <glib.h>
#include "wmem_core.h"
-#include "wmem_slab.h"
#include "wmem_slist.h"
struct _wmem_slist_frame_t {
@@ -38,7 +37,7 @@ struct _wmem_slist_frame_t {
struct _wmem_slist_t {
guint count;
wmem_slist_frame_t *front;
- wmem_slab_t *slab;
+ wmem_allocator_t *allocator;
};
guint
@@ -94,7 +93,7 @@ wmem_slist_remove(wmem_slist_t *slist, void *data)
*link = frame->next;
slist->count--;
- wmem_slab_free(slist->slab, frame);
+ wmem_free(slist->allocator, frame);
}
void
@@ -102,7 +101,7 @@ wmem_slist_prepend(wmem_slist_t *slist, void *data)
{
wmem_slist_frame_t *new;
- new = (wmem_slist_frame_t *) wmem_slab_alloc(slist->slab);
+ new = wmem_new(slist->allocator, wmem_slist_frame_t);
new->data = data;
new->next = slist->front;
@@ -118,9 +117,9 @@ wmem_slist_new(wmem_allocator_t *allocator)
slist = (wmem_slist_t *) wmem_alloc(allocator, sizeof(wmem_slist_t));
- slist->count = 0;
- slist->front = NULL;
- slist->slab = wmem_slab_new(allocator, sizeof(wmem_slist_frame_t));
+ slist->count = 0;
+ slist->front = NULL;
+ slist->allocator = allocator;
return slist;
}
diff --git a/epan/wmem/wmem_stack.c b/epan/wmem/wmem_stack.c
index 2dbd910ae4..4fd1d0c3f7 100644
--- a/epan/wmem/wmem_stack.c
+++ b/epan/wmem/wmem_stack.c
@@ -27,7 +27,6 @@
#include <glib.h>
#include "wmem_core.h"
-#include "wmem_slab.h"
#include "wmem_stack.h"
#include "wmem_slist.h"
diff --git a/tools/test-common.sh b/tools/test-common.sh
index faa0155792..ee56b6e0ee 100755
--- a/tools/test-common.sh
+++ b/tools/test-common.sh
@@ -67,7 +67,6 @@ export WIRESHARK_EP_VERIFY_POINTERS=
export WIRESHARK_SE_VERIFY_POINTERS=
# Use the Wmem strict allocator which does canaries and scrubbing etc.
export WIRESHARK_DEBUG_WMEM_OVERRIDE=strict
-export WIRESHARK_DEBUG_WMEM_SLAB=
# Turn on GLib memory debugging (since 2.13)
export G_SLICE=debug-blocks
diff --git a/tools/valgrind-wireshark.sh b/tools/valgrind-wireshark.sh
index 783fd98d89..08fe355de6 100755
--- a/tools/valgrind-wireshark.sh
+++ b/tools/valgrind-wireshark.sh
@@ -80,7 +80,6 @@ fi
export WIRESHARK_DEBUG_EP_NO_CHUNKS=
export WIRESHARK_DEBUG_SE_NO_CHUNKS=
export WIRESHARK_DEBUG_WMEM_OVERRIDE=simple
-export WIRESHARK_DEBUG_WMEM_SLAB=
export G_SLICE=always-malloc # or debug-blocks
libtool --mode=execute valgrind $VERBOSE $LEAK_CHECK $REACHABLE $TRACK_ORIGINS $BIN_DIR/$COMMAND $COMMAND_ARGS $PCAP $COMMAND_ARGS2 > /dev/null