-
Notifications
You must be signed in to change notification settings - Fork 0
/
array.h
66 lines (53 loc) · 1.57 KB
/
array.h
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
61
62
63
64
65
/* array.h */
/*
copyright 1991-1996,2014-2016 Michael D. Brennan
This is a source file for mawk, an implementation of
the AWK programming language.
Mawk is distributed without warranty under the terms of
the GNU General Public License, version 3, 2007.
array.c and array.h were generated with the commands
notangle -R'"array.c"' array.w > array.c
notangle -R'"array.h"' array.w > array.h
Notangle is part of Norman Ramsey's noweb literate programming package.
Noweb home page: http://www.cs.tufts.edu/~nr/noweb/
It's easiest to read or modify this file by working with array.w.
*/
#ifndef ARRAY_H
#define ARRAY_H 1
#include "types.h"
#include "types_int.h"
typedef struct array {
void* ptr ; /* What this points to depends on the type */
size_t size ; /* number of elts in the table */
int type ; /* values in AY_NULL .. AY_SPLIT */
} *ARRAY ;
enum {
AY_NULL = 0,
AY_SPLIT,
AY_STR,
AY_INT
} ;
#define new_ARRAY() ((ARRAY)memset(ZMALLOC(struct array),0,sizeof(struct array)))
#define NO_CREATE 0
#define CREATE 1
#define DELETE_ 2
typedef struct aloop {
struct aloop* link ;
int type ; /* AY_NULL .. AY_INT */
unsigned size ;
unsigned next ;
CELL* cp ;
union {
STRING** sval ; /* for AY_STR */
int64_t* ival ; /* for AY_INT */
} ptr ;
} ALoop ;
CELL* array_find(ARRAY, CELL*, int);
void array_delete(ARRAY, CELL*);
void array_load(ARRAY, size_t);
void array_clear(ARRAY);
CELL* array_cat(CELL*, int);
ALoop* make_aloop(ARRAY, CELL*) ;
void aloop_free(ALoop*) ;
int aloop_next(ALoop*) ;
#endif /* ARRAY_H */