/+junk/c_sdl_joypad

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include <stdlib.h>

/*
 * This file, as the rest of the project is under MIT license.
 * see http://opensource.org/licenses/MIT
 *
 * Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
 */

/** @file
 * Dynamic Array.
 *
 * This file contains an imlpementation of a "dynamic" array, it is usefule when
 * dealing with lare amounts of data that may change over time, or with an
 * unknowned numebr of items.
 * 
 * Note that accsess time is constant, but write time is not guarenteed to be.
 * 
 * When the size of the array is equal to the number of elements in it, it will
 * re-allocate the array with a larger size.
 */

/**
 * The padding that is added when expanding the array.
 */
#define ARRAY_PADDING 8

/**
 * Represents a for each function.
 * 
 * @param self the dynamic array.
 * @param data the data to be passed to the each iteration.
 * @returns data to be put in a new DynamicArray, if used with
 * dynamic_array_for_each_with_return.
 */
typedef void * (* ForEachFunc)(DynamicArray * self, void * data);

/**
 * an opaque data structure that represents the dynamic array.
 */
typedef struct _DynamicArray DynamicArray;

/**
 * Create a new dynamic array.
 *
 * @param len The length of the initial array.
 * @param item_size The size of the items to be stored.
 */
DymamicArray * dynamic_array_new (size_t len);

/**
 * Frees the dynamic array.
 * 
 * after this is run the data will be lost.
 */
void dynamic_array_free (DynamicArray * self);


/**
 * Get an item from the array.
 */
void * dynamic_array_get (DynamicArray * self, int index);

/**
 * Get the length of the array.
 */
size_t dymanic_array_len (DynamicArray * self);


/**
 * Add an item to the array.
 */
void dynamic_array_add (DynamicArray * self, void * item);

/**
 * Dumps a copy of the. Must be cast.
 * 
 * Is not freed when the dynamic array is freed.
 * 
 * Is null-terminated.
 */
void ** dynamic_array_dump_array (DynamicArray * self);

/**
 * Use a function on the array.
 */
void dynamic_array_for_each (DynamicArray * self, ForEachFunc func,
                             void * data);

/**
 * same as dynamic_array_for_each (), with the difference that it returns a new
 * DynamicArray.
 */
DynamicArray * dynamic_array_for_each_with_return (DynamicArray * self,
                                                   ForEachFunc func,
                                                   void * data);