~ubuntu-branches/ubuntu/lucid/codelite/lucid

« back to all changes in this revision

Viewing changes to sdk/ctags/clist.c

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2009-02-10 02:27:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090210022755-m5692nfc1t5uf1w9
Tags: 1.0.2759+dfsg-0ubuntu1
* New upstream release (LP: #327216).
* debian/patches/series, debian/patches/00_fix-ia64-build.patch:
  + Dropped, applied upstream already.
* debian/patches/02_fix-desktop.patch,
  debian/patches/03_fix-sh.patch:
  + Refreshed to patch cleanly.
* debian/rules:
  + Make get-orig-source honour UPSTREAM_VERSION if set.
* debian/ctags-le.1,
  debian/codelite_indexer.1,
  debian/codelite.manpages:
  + Dropped ctags-le manpage, since ctags-le was replaced by
    codelite_indexer.
  + Added codelite_indexer manpage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "clist.h"
2
 
#include <stdlib.h>
3
 
 
4
 
/*
5
 
 *----------------------------------------------------------------
6
 
 * private methods
7
 
 *----------------------------------------------------------------
8
 
 *
9
 
 */
10
 
static list_node_t *list_new_node()
11
 
{
12
 
        list_node_t *node = (list_node_t *)malloc(sizeof(list_node_t));
13
 
        node->data = 0;
14
 
        node->next = 0;
15
 
        node->prev = 0;
16
 
 
17
 
        return node;
18
 
}
19
 
 
20
 
/*
21
 
 *----------------------------------------------------------------
22
 
 * API
23
 
 *----------------------------------------------------------------
24
 
 *
25
 
 */
26
 
void list_init(list_t** lst)
27
 
{
28
 
        *lst = (list_t*)malloc(sizeof(list_t));
29
 
        list_t *l = *lst;
30
 
        l->head = (list_node_t*)0;
31
 
        l->last = (list_node_t*)0;
32
 
        l->size = 0;
33
 
}
34
 
 
35
 
void list_append(list_t* lst, void* data)
36
 
{
37
 
        list_node_t *node = list_new_node();
38
 
        node->data = data;
39
 
 
40
 
        if (lst->last) {
41
 
                /* we have last item, just append the new one */
42
 
                lst->last->next = node;
43
 
                node->prev = lst->last;
44
 
                lst->last = node;
45
 
 
46
 
        } else {
47
 
                /* no items in the list */
48
 
                lst->last = node;
49
 
                lst->head = node;
50
 
        }
51
 
        lst->size++;
52
 
}
53
 
 
54
 
void list_destroy(list_t* lst)
55
 
{
56
 
        list_node_t *node = lst->head;
57
 
        while(node) {
58
 
                list_node_t *next = node->next;
59
 
                free(node);
60
 
                node = next;
61
 
        }
62
 
        lst->size = 0;
63
 
        lst->head = 0;
64
 
        lst->last = 0;
65
 
}