source: vis_dev/vl2mv-2.3/src/stack/stack.c @ 91

Last change on this file since 91 was 18, checked in by cecile, 13 years ago

vl2mv added

File size: 1.5 KB
Line 
1/*
2 *  Utilities for handling sets.
3 *
4 *  Copyright (c) 1992, 1993
5 *        Regents of the University of California
6 *  All rights reserved.
7 *
8 *  Use and copying of this software and preparation of derivative works
9 *  based upon this software are permitted.  However, any distribution of
10 *  this software or derivative works must include the above copyright
11 *  notice.
12 *
13 *  This software is made available AS IS, and neither the Electronics
14 *  Research Laboratory or the Universify of California make any
15 *  warranty about the software, its performance or its conformity to
16 *  any specification.
17 *
18 *  $Header: /projects/development/hsv/CVSRepository/vl2mv/src/stack/stack.c,v 1.1.1.1 2001/07/09 23:22:44 fabio Exp $
19 *
20 * Author: STCheng, stcheng@ic.berkeley.edu
21 */
22
23#include <stdio.h>
24#include "util.h"
25#include "list.h"
26#include "stack.h"
27
28lsList create_stack()
29{
30    return lsCreate();
31}
32
33void destroy_stack(stack, del_func)
34lsList stack;
35void (*del_func)();
36{
37    (void) lsDestroy(stack, del_func);
38}
39
40void push_stack(obj_stack, item)
41lsList obj_stack;
42void *item;
43{
44    lsNewEnd(obj_stack, item, 0);
45}
46
47void *pop_stack(obj_stack, item)
48lsList obj_stack;
49void **item;
50{
51    if (lsDelEnd(obj_stack, (lsGeneric*)item) == LS_NOMORE) {
52        *item = NIL(void);
53        return *item;
54    } 
55
56    return *item;
57}
58
59void *top_stack(obj_stack)
60lsList obj_stack;
61{
62    void *item;
63
64    if (lsLastItem(obj_stack, (lsGeneric*)&item, 0) == LS_NOMORE) {
65        item = NIL(void);
66        return item;
67    }
68
69    return item;
70}
Note: See TracBrowser for help on using the repository browser.