5807fdf68fbbaa2a68cd315b9f7071ba0f6dfd0f
[ipc/ipcdev.git] / qnx / src / ipc3x_dev / ti / syslink / procMgr / hlos / knl / loaders / Elf / Qnx / DLOAD / DLOAD / ArrayList.h
1 /*
2 * ArrayList.h
3 *
4 * This implementation of ArrayList is a replacement for the C++
5 * vector class in C.
6 *
7 * This class emulates a resizable array along the lines of a C++
8 * vector or Java ArrayList class in C, and uses the convention
9 * of passing a pointer to the current "object" as the first
10 * argument.
11 *
12 * Usage is defined as follows:
13 *
14 * Array_List obj;
15 * AL_initialize(&obj, sizeof(type_name));
16 *
17 * ...
18 *
19 * type_name *ptr = (type_name*)(obj.buf);
20 * for(i = 0; i < AL_size(&obj); i++)
21 * do_something_to(ptr[i]);
22 * type_name to_append = ...;
23 * AL_append(&obj, &to_append);
24 *
25 * ...
26 *
27 * AL_destroy(&obj);
28 *
29 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
30 *
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 *
36 * Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer.
38 *
39 * Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the
42 * distribution.
43 *
44 * Neither the name of Texas Instruments Incorporated nor the names of
45 * its contributors may be used to endorse or promote products derived
46 * from this software without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
51 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
52 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
53 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
54 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
55 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
56 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
57 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
58 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
59 *
60 */
62 #ifndef ARRAYLIST_H
63 #define ARRAYLIST_H
65 #if defined (__KERNEL__)
66 #include <linux/types.h>
67 #else
68 #include <inttypes.h>
69 #endif
71 /**********************************************************************/
72 /* Array_List - structure type specification. */
73 /**********************************************************************/
74 typedef struct
75 {
76 void *buf;
77 int32_t type_size;
78 int32_t size;
79 int32_t buffer_size;
80 } Array_List;
82 /*--------------------------------------------------------------------*/
83 /* Array_List Member Functions: */
84 /* */
85 /* AL_initialize() - Initialize a newly created Array_List object. */
86 /* AL_append() - Append an element to the end of an Array_List. */
87 /* AL_size() - Get number of elements in an Array_List. */
88 /* AL_destroy() - Free memory associated with an Array_List that is */
89 /* no longer in use. */
90 /*--------------------------------------------------------------------*/
91 void AL_initialize(Array_List* obj, int32_t type_size, int32_t num_elem);
92 void AL_append(Array_List* obj, void* to_append);
93 int32_t AL_size(Array_List* obj);
94 void AL_destroy(Array_List* obj);
96 #endif