Remove the wmem slab. It was an optimization mimicking the emem slab

(removed in r48218) which did nothing particularly useful. Also lets us remove
another debugging environment variable.

svn path=/trunk/; revision=48219
This commit is contained in:
Evan Huus 2013-03-09 20:16:33 +00:00
parent 122b7cb6df
commit aafe8b18e9
10 changed files with 7 additions and 221 deletions

View File

@ -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

View File

@ -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

View File

@ -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 \

View File

@ -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"

View File

@ -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:
*/

View File

@ -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:
*/

View File

@ -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;
}

View File

@ -27,7 +27,6 @@
#include <glib.h>
#include "wmem_core.h"
#include "wmem_slab.h"
#include "wmem_stack.h"
#include "wmem_slist.h"

View File

@ -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

View File

@ -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