Ignore:
Timestamp:
03/03/10 14:24:58 (14 years ago)
Author:
tim
Message:

filled in additional, minimal documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/void_stack.h

    r168 r169  
    1 /**
    2  * @file
    3  *
    4  * Copyright (C) 2005,2007,2009 Timothy D. Morgan
     1/*
     2 * Copyright (C) 2005,2007,2009-2010 Timothy D. Morgan
    53 *
    64 * This program is free software; you can redistribute it and/or modify
     
    2018 */
    2119
     20/**
     21 *@file
     22 *
     23 * This is a very simple implementation of a stack which stores chunks of
     24 * memory of any type.
     25 */
     26
     27
    2228#ifndef _VOID_STACK_H
    2329#define _VOID_STACK_H
     
    2834#include "talloc.h"
    2935
     36/** XXX: document this. */
    3037typedef struct _void_stack
    3138{
     
    3542} void_stack;
    3643
     44
     45/** XXX: document this. */
    3746typedef struct _void_stack_iterator
    3847{
     
    4251
    4352
    44 /* void_stack_new():
    45  *  Allocates a new void_stack.
     53/** Allocates a new void_stack.
    4654 *
    47  * Arguments:
    48  *  max_size -- the maxiumum number of elements
    49  *              which may be pushed onto the stack.
     55 * @param max_size the maxiumum number of elements
     56 *                 which may be pushed onto the stack.
    5057 *
    51  * Returns:
    52  *  a pointer to the newly allocated void_stack, or NULL if an error occurred.
     58 * @return a pointer to the newly allocated void_stack,
     59 *        or NULL if an error occurred.
    5360 */
    5461void_stack* void_stack_new(unsigned short max_size);
    5562
    5663
    57 /* void_stack_copy():
    58  *  Makes a shallow copy of void_stack.
     64/** Makes a shallow copy of void_stack.
    5965 *
    60  * Arguments:
    61  *  v -- the stack to make a copy of.
     66 * @param v the stack to make a copy of.
    6267 *
    63  * Returns:
    64  *  a pointer to the duplicate void_stack, or NULL If an error occurred.
     68 * @return a pointer to the duplicate void_stack, or NULL if an error occurred.
    6569 */
    6670void_stack* void_stack_copy(const void_stack* v);
    6771
    6872
    69 /* void_stack_copy_reverse():
    70  *  Makes a shallow copy of void_stack in reverse order.
     73/** Makes a shallow copy of void_stack in reverse order.
    7174 *
    72  * Arguments:
    73  *  v -- the stack to make a copy of.
     75 * @param v the stack to make a copy of.
    7476 *
    75  * Returns:
    76  *  a pointer to the duplicate void_stack (which will be in reverse order),
    77  *  or NULL If an error occurred.
     77 * @return a pointer to the duplicate void_stack
     78 *         (which will be in reverse order), or NULL if an error occurred.
    7879 */
    7980void_stack* void_stack_copy_reverse(const void_stack* v);
    8081
    8182
    82 /* void_stack_free():
    83  *  Frees the memory associated with a void_stack, but not the elements held
     83/** Frees the memory associated with a void_stack, but not the elements held
    8484 *  on the stack.
    8585 *
    86  * Arguments:
    87  *  stack -- the stack to be free()d.
     86 * @param stack the stack to be free()d.
    8887 */
    8988void void_stack_free(void_stack* stack);
    9089
    9190
    92 /* void_stack_free_deep():
    93  *  Frees the memory associated with a void_stack and the elements referenced
    94  *  by the stack.  Do not use this function if the elements of the stack
    95  *  are also free()d elsewhere, or contain pointers to other memory which
    96  *  cannot be otherwise free()d.
     91/** Frees the memory associated with a void_stack and the elements referenced
     92 *  by the stack. 
    9793 *
    98  * Arguments:
    99  *  stack -- the stack to be free()d.
     94 * Do not use this function if the elements of the stack
     95 * are also free()d elsewhere, or contain pointers to other memory which
     96 * cannot be otherwise free()d.
     97 *
     98 * @param stack the stack to be free()d.
    10099 */
    101100void void_stack_free_deep(void_stack* stack);
    102101
    103102
    104 /* void_stack_size():
    105  *  Query the current number of elements on a void_stack()
     103/** Query the current number of elements on a void_stack()
    106104 *
    107  * Arguments:
    108  *  stack -- the void_stack to query
     105 * @param stack the void_stack to query
    109106 *
    110  * Returns:
    111  *  the number of elements currently on the stack.
     107 * @return the number of elements currently on the stack.
    112108 */
    113109unsigned short void_stack_size(const void_stack* stack);
    114110
    115111
    116 /* void_stack_pop():
    117  *  Removes the top element on a void_stack and returns a reference to it.
     112/** Removes the top element on a void_stack and returns a reference to it.
    118113 *
    119  * Arguments:
    120  *  stack -- the void_stack to pop
     114 * @param stack the void_stack to pop
    121115 *
    122  * Returns:
    123  *  a pointer to the popped stack element, or NULL if no elements exist on
    124  *  the stack.
     116 * @return a pointer to the popped stack element, or NULL if no elements exist
     117 *         on the stack.
    125118 */
    126119void* void_stack_pop(void_stack* stack);
    127120
    128121
    129 /* void_stack_push():
    130  *  Puts a new element on the top of a void_stack.
     122/** Puts a new element on the top of a void_stack.
    131123 *
    132  * Arguments:
    133  *  stack -- the void_stack being modified.
     124 * @param stack the void_stack being modified.
     125 * @param e the element to be added
    134126 *
    135  *  e     -- the element to be added
    136  *
    137  * Returns:
    138  *  true if the element was successfully added, false otherwise.
     127 * @return true if the element was successfully added, false otherwise.
    139128 */
    140129bool void_stack_push(void_stack* stack, void* e);
    141130
    142131
    143 /* void_stack_cur():
    144  *  Returns a pointer to the current element on the top of the stack.
     132/** Returns a pointer to the current element on the top of the stack.
    145133 *
    146  * Arguments:
    147  *  stack -- the void_stack being queried.
     134 * @param stack the void_stack being queried.
    148135 *
    149  * Returns:
    150  *  a pointer to the current element on the top of the stack, or NULL if no
    151  *  elements exist in the stack.
     136 * @return a pointer to the current element on the top of the stack, or NULL if
     137 *         no elements exist in the stack.
    152138 */
    153139const void* void_stack_cur(const void_stack* stack);
    154140
    155141
    156 /* void_stack_iterator_new():
    157  *  Creates a new iterator for the specified void_stack.
     142/** Creates a new iterator for the specified void_stack.
    158143 *
    159  * Arguments:
    160  *  stack -- the void_stack to be referenced by the new iterator
     144 * @param stack the void_stack to be referenced by the new iterator
    161145 *
    162  * Returns:
    163  *  a new void_stack_iterator, or NULL if an error occurred.
     146 * @return a new void_stack_iterator, or NULL if an error occurred.
    164147 */
    165148void_stack_iterator* void_stack_iterator_new(const void_stack* stack);
    166149
    167150
    168 /* void_stack_iterator_free():
    169  *  Frees a void_stack_iterator.  Does not affect the void_stack referenced
    170  *  by the iterator.
     151/** Frees a void_stack_iterator.
    171152 *
    172  * Arguments:
    173  *  iter -- the void_stack_iterator to be free()d.
     153 * Does not affect the void_stack referenced by the iterator.
     154 *
     155 * @param iter the void_stack_iterator to be free()d.
    174156 */
    175157void void_stack_iterator_free(void_stack_iterator* iter);
    176158
    177159
    178 /* void_stack_iterator_next():
    179  *  Returns a pointer to the the next element in the stack.  Iterates over
    180  *  elements starting in order from the oldest element (bottom of the stack).
     160/** Returns a pointer to the the next element in the stack.
    181161 *
    182  * Arguments:
    183  *  iter -- the void_stack_iterator used to lookup the next element.
     162 * Iterates over elements starting in order from the oldest element (bottom of the stack).
    184163 *
    185  * Returns:
    186  *  a pointer to the next element.
     164 * @param iter the void_stack_iterator used to lookup the next element.
     165 *
     166 * @return a pointer to the next element.
    187167 */
    188168const void* void_stack_iterator_next(void_stack_iterator* iter);
Note: See TracChangeset for help on using the changeset viewer.