File: array.h

package info (click to toggle)
neverball 1.6.0%2Bgit20180603-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 152,380 kB
  • sloc: ansic: 27,402; makefile: 454; cpp: 208; xml: 177; sh: 161
file content (41 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (4)
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
#ifndef ARRAY_H
#define ARRAY_H

/*----------------------------------------------------------------------------*/

/*
 * Array allocator that minimizes allocations.
 */

struct alloc
{
    void **data;
    int   *count;

    int size;
    int block;
};

void  alloc_new(struct alloc *, int, void **, int *);
void  alloc_free(struct alloc *);
void *alloc_add(struct alloc *);
void  alloc_del(struct alloc *);

/*----------------------------------------------------------------------------*/

typedef struct array *Array;

Array array_new(int);
void  array_free(Array);

void *array_add(Array);
void  array_del(Array);
void *array_get(Array, int);
void *array_rnd(Array);
int   array_len(Array);

void  array_sort(Array, int (*cmp)(const void *, const void *));

/*----------------------------------------------------------------------------*/

#endif