• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/alsa-lib-1.0.26/src/mixer/

Lines Matching defs:*

2  *  Bag of pointers
3 * Copyright (c) 2001 by Abramo Bagnara <abramo@alsa-project.org>
6 * This library is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "mixer_local.h"
24 int bag_new(bag_t **bag)
26 bag_t *b = malloc(sizeof(*b));
27 if (!b)
28 return -ENOMEM;
29 INIT_LIST_HEAD(b);
30 *bag = b;
31 return 0;
34 void bag_free(bag_t *bag)
36 assert(list_empty(bag));
37 free(bag);
40 int bag_empty(bag_t *bag)
42 return list_empty(bag);
45 int bag_add(bag_t *bag, void *ptr)
47 bag1_t *b = malloc(sizeof(*b));
48 if (!b)
49 return -ENOMEM;
50 b->ptr = ptr;
51 list_add_tail(&b->list, bag);
52 return 0;
55 int bag_del(bag_t *bag, void *ptr)
57 struct list_head *pos;
58 list_for_each(pos, bag) {
59 bag1_t *b = list_entry(pos, bag1_t, list);
60 if (b->ptr == ptr) {
61 list_del(&b->list);
62 free(b);
63 return 0;
66 return -ENOENT;
69 void bag_del_all(bag_t *bag)
71 while (!list_empty(bag))
72 list_del(bag->next);