Blame glib/glib/gtrashstack.c

Packit db3073
/* GLIB - Library of useful routines for C programming
Packit db3073
 * Copyright (C) 1995-1998  Peter Mattis, Spencer Kimball and Josh MacDonald
Packit db3073
 *
Packit db3073
 * This library is free software; you can redistribute it and/or
Packit db3073
 * modify it under the terms of the GNU Lesser General Public
Packit db3073
 * License as published by the Free Software Foundation; either
Packit db3073
 * version 2 of the License, or (at your option) any later version.
Packit db3073
 *
Packit db3073
 * This library is distributed in the hope that it will be useful,
Packit db3073
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit db3073
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the GNU
Packit db3073
 * Lesser General Public License for more details.
Packit db3073
 *
Packit db3073
 * You should have received a copy of the GNU Lesser General Public
Packit db3073
 * License along with this library; if not, write to the
Packit db3073
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Packit db3073
 * Boston, MA 02111-1307, USA.
Packit db3073
 */
Packit db3073
Packit db3073
/*
Packit db3073
 * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
Packit db3073
 * file for a list of people on the GLib Team.  See the ChangeLog
Packit db3073
 * files for a list of changes.  These files are distributed with
Packit db3073
 * GLib at ftp://ftp.gtk.org/pub/gtk/. 
Packit db3073
 */
Packit db3073
Packit db3073
#include "config.h"
Packit db3073
Packit db3073
/**
Packit db3073
 * SECTION:trash_stack
Packit db3073
 * @title: Trash Stacks
Packit db3073
 * @short_description: maintain a stack of unused allocated memory chunks
Packit db3073
 *
Packit db3073
 * A #GTrashStack is an efficient way to keep a stack of unused allocated
Packit db3073
 * memory chunks. Each memory chunk is required to be large enough to hold
Packit db3073
 * a #gpointer. This allows the stack to be maintained without any space
Packit db3073
 * overhead, since the stack pointers can be stored inside the memory chunks.
Packit db3073
 *
Packit db3073
 * There is no function to create a #GTrashStack. A %NULL #GTrashStack*
Packit db3073
 * is a perfectly valid empty stack.
Packit db3073
 */
Packit db3073
Packit db3073
/**
Packit db3073
 * GTrashStack:
Packit db3073
 * @next: pointer to the previous element of the stack,
Packit db3073
 *     gets stored in the first <literal>sizeof (gpointer)</literal>
Packit db3073
 *     bytes of the element
Packit db3073
 *
Packit db3073
 * Each piece of memory that is pushed onto the stack
Packit db3073
 * is cast to a <structname>GTrashStack*</structname>.
Packit db3073
 */
Packit db3073
Packit db3073
/**
Packit db3073
 * g_trash_stack_push:
Packit db3073
 * @stack_p: a #GTrashStack
Packit db3073
 * @data_p: the piece of memory to push on the stack
Packit db3073
 *
Packit db3073
 * Pushes a piece of memory onto a #GTrashStack.
Packit db3073
 */
Packit db3073
Packit db3073
/**
Packit db3073
 * g_trash_stack_pop:
Packit db3073
 * @stack_p: a #GTrashStack
Packit db3073
 *
Packit db3073
 * Pops a piece of memory off a #GTrashStack.
Packit db3073
 *
Packit db3073
 * Returns: the element at the top of the stack
Packit db3073
 */
Packit db3073
Packit db3073
/**
Packit db3073
 * g_trash_stack_peek:
Packit db3073
 * @stack_p: a #GTrashStack
Packit db3073
 *
Packit db3073
 * Returns the element at the top of a #GTrashStack
Packit db3073
 * which may be %NULL.
Packit db3073
 *
Packit db3073
 * Returns: the element at the top of the stack
Packit db3073
 */
Packit db3073
Packit db3073
/**
Packit db3073
 * g_trash_stack_height:
Packit db3073
 * @stack_p: a #GTrashStack
Packit db3073
 *
Packit db3073
 * Returns the height of a #GTrashStack.
Packit db3073
 *
Packit db3073
 * Note that execution of this function is of O(N) complexity
Packit db3073
 * where N denotes the number of items on the stack.
Packit db3073
 *
Packit db3073
 * Returns: the height of the stack
Packit db3073
 */
Packit db3073
Packit db3073
#define G_IMPLEMENT_INLINES 1
Packit db3073
#define __G_TRASH_STACK_C__
Packit db3073
#include "gtrashstack.h"