File: slab.h

package info (click to toggle)
xfsprogs 4.9.0+nmu1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 8,012 kB
  • ctags: 10,574
  • sloc: ansic: 110,850; sh: 3,804; makefile: 863; python: 126
file content (60 lines) | stat: -rw-r--r-- 2,186 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * Copyright (C) 2016 Oracle.  All Rights Reserved.
 *
 * Author: Darrick J. Wong <darrick.wong@oracle.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it would be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write the Free Software Foundation,
 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
 */
#ifndef SLAB_H_
#define SLAB_H_

struct xfs_slab;
struct xfs_slab_cursor;

extern int init_slab(struct xfs_slab **, size_t);
extern void free_slab(struct xfs_slab **);

extern int slab_add(struct xfs_slab *, void *);
extern void qsort_slab(struct xfs_slab *, int (*)(const void *, const void *));
extern size_t slab_count(struct xfs_slab *);

extern int init_slab_cursor(struct xfs_slab *,
	int (*)(const void *, const void *), struct xfs_slab_cursor **);
extern void free_slab_cursor(struct xfs_slab_cursor **);

extern void *peek_slab_cursor(struct xfs_slab_cursor *);
extern void advance_slab_cursor(struct xfs_slab_cursor *);
extern void *pop_slab_cursor(struct xfs_slab_cursor *);

struct xfs_bag;

extern int init_bag(struct xfs_bag **);
extern void free_bag(struct xfs_bag **);
extern int bag_add(struct xfs_bag *, void *);
extern int bag_remove(struct xfs_bag *, size_t);
extern size_t bag_count(struct xfs_bag *);
extern void *bag_item(struct xfs_bag *, size_t);

#define foreach_bag_ptr(bag, idx, ptr) \
	for ((idx) = 0, (ptr) = bag_item((bag), (idx)); \
	     (idx) < bag_count(bag); \
	     (idx)++, (ptr) = bag_item((bag), (idx)))

#define foreach_bag_ptr_reverse(bag, idx, ptr) \
	for ((idx) = bag_count(bag) - 1, (ptr) = bag_item((bag), (idx)); \
	     (ptr) != NULL; \
	     (idx)--, (ptr) = bag_item((bag), (idx)))

#endif /* SLAB_H_ */