2012-11-03 17:34:28 +00:00
|
|
|
/* wmem_stack.c
|
|
|
|
* Wireshark Memory Manager Stack
|
|
|
|
* Copyright 2012, Evan Huus <eapache@gmail.com>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-08 16:31:35 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2012-11-03 17:34:28 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <glib.h>
|
|
|
|
|
2021-07-09 18:46:39 +00:00
|
|
|
#include "wmem-int.h"
|
2012-11-03 17:34:28 +00:00
|
|
|
#include "wmem_core.h"
|
|
|
|
#include "wmem_stack.h"
|
2013-07-20 20:33:38 +00:00
|
|
|
#include "wmem_list.h"
|
2012-11-03 17:34:28 +00:00
|
|
|
|
2013-07-20 20:33:38 +00:00
|
|
|
/* Wmem stack is implemented as a simple wrapper over Wmem list */
|
2012-11-03 17:34:28 +00:00
|
|
|
|
|
|
|
void *
|
2012-11-08 23:18:26 +00:00
|
|
|
wmem_stack_peek(const wmem_stack_t *stack)
|
2012-11-03 17:34:28 +00:00
|
|
|
{
|
2013-07-20 20:33:38 +00:00
|
|
|
wmem_list_frame_t *frame;
|
2012-12-19 01:37:28 +00:00
|
|
|
|
2013-07-20 20:33:38 +00:00
|
|
|
frame = wmem_list_head(stack);
|
2012-11-03 17:34:28 +00:00
|
|
|
|
2021-07-09 18:46:39 +00:00
|
|
|
ASSERT(frame);
|
2012-12-19 01:37:28 +00:00
|
|
|
|
2013-07-20 20:33:38 +00:00
|
|
|
return wmem_list_frame_data(frame);
|
2012-11-03 17:34:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
wmem_stack_pop(wmem_stack_t *stack)
|
|
|
|
{
|
|
|
|
void *data;
|
|
|
|
|
2012-12-19 01:37:28 +00:00
|
|
|
data = wmem_stack_peek(stack);
|
2012-11-03 17:34:28 +00:00
|
|
|
|
2013-07-20 20:33:38 +00:00
|
|
|
wmem_list_remove(stack, data);
|
2012-11-03 17:34:28 +00:00
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2012-11-03 17:34:28 +00:00
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*/
|