File: array.h

package info (click to toggle)
hunt 1.5-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 472 kB
  • ctags: 958
  • sloc: ansic: 10,245; makefile: 84; sh: 14
file content (59 lines) | stat: -rw-r--r-- 1,212 bytes parent folder | download | duplicates (7)
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
/*
 * 
 *	This is free software. You can redistribute it and/or modify under
 *	the terms of the GNU General Public License version 2.
 *
 * 	Copyright (C) 1998 by kra
 * 
 */
#ifndef __ARRAY_H
#define __ARRAY_H

#ifdef _REENTRANT
#include <pthread.h>
#endif

struct array_item {
	void *ai_data;
};

struct array {
	struct array_item *a_arr;
	int a_size;
	int a_items;
#ifdef _REENTRANT
	int a_locked;
	pthread_t a_locked_thr;
	pthread_mutex_t a_mutex;
#endif
};

#define ARRAY_SPACE_PCT_INC	50

void array_init(struct array *a, int size);
void array_free(struct array *a);

void *array_at(struct array *a, int nr);
void *array_remove(struct array *a, void *m);
void *array_remove_at(struct array *a, int nr);

int array_put(struct array *a, void *m);
void *array_put_at(struct array *a, int nr, void *m);

void *array_pop(struct array *a);

int array_count(struct array *a);

struct array_iterator {
	struct array *i_array;
	int i_pos;
};

void array_iter_set(struct array_iterator *ai, struct array *a);
void *array_iter_get(struct array_iterator *ai);
void array_iter_end(struct array_iterator *ai);

void array_iter_lock(struct array_iterator *ai);
void array_iter_unlock(struct array_iterator *ai);

#endif