3 * cpulimit - a cpu limiter for Linux
5 * Copyright (C) 2005-2008, by: Angelo Marletta <marlonx80@hotmail.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 **********************************************************************
23 * Dynamic list interface
41 //pointer to the content of the node
43 //pointer to previous node
44 struct list_node *previous;
45 //pointer to next node
46 struct list_node *next;
51 struct list_node *first;
53 struct list_node *last;
54 //size of the search key in bytes
61 * Initialize a list, with a specified key size
63 void init_list(struct list *l,int keysize);
66 * Add a new element at the end of the list
67 * return the pointer to the new node
69 struct list_node *add_elem(struct list *l,void *elem);
74 void delete_node(struct list *l,struct list_node *node);
77 * Delete a node from the list, even the content pointed by it
78 * Use only when the content is a dynamically allocated pointer
80 void destroy_node(struct list *l,struct list_node *node);
83 * Check whether a list is empty or not
85 int is_empty_list(struct list *l);
88 * Return the element count of the list
90 int get_list_count(struct list *l);
93 * Return the first element (content of the node) from the list
95 void *first_elem(struct list *l);
98 * Return the first node from the list
100 struct list_node *first_node(struct list *l);
103 * Return the last element (content of the node) from the list
105 void *last_elem(struct list *l);
108 * Return the last node from the list
110 struct list_node *last_node(struct list *l);
113 * Search an element of the list by content
114 * the comparison is done from the specified offset and for a specified length
115 * if offset=0, the comparison starts from the address pointed by data
116 * if length=0, default keysize is used for length
117 * if the element is found, return the node address
120 struct list_node *xlocate_node(struct list *l,void *elem,int offset,int length);
123 * The same of xlocate_node(), but return the content of the node
125 void *xlocate_elem(struct list *l,void *elem,int offset,int length);
128 * The same of calling xlocate_node() with offset=0 and length=0
130 struct list_node *locate_node(struct list *l,void *elem);
133 * The same of locate_node, but return the content of the node
135 void *locate_elem(struct list *l,void *elem);
138 * Delete all the elements in the list
140 void flush_list(struct list *l);
143 * Delete every element in the list, and free the memory pointed by all the node data
145 void destroy_list(struct list *l);