|
Tesseract
3.02
|
#include <stdio.h>Go to the source code of this file.
Classes | |
| struct | array_record |
Defines | |
| #define | DEFAULT_SIZE 2 |
| #define | array_count(a) ((a)->top) |
| #define | array_free memfree |
| #define | array_index(a, i) ((i<array_count(a)) ? (a)->base[i] : 0) |
| #define | array_limit(a) ((a)->limit) |
| #define | array_loop(a, x) for (x=0; x < array_count (a); x++) |
| #define | array_top(a) ((a)->base[array_count (a) - 1]) |
| #define | array_value(a, i) ((a)->base[i]) |
Typedefs | |
| typedef struct array_record * | ARRAY |
| typedef void(* | voidProc )() |
| typedef int(* | intProc )() |
Functions | |
| ARRAY | array_insert (ARRAY array, int index, void *value) |
| ARRAY | array_new (int num) |
| ARRAY | array_push (ARRAY array, void *value) |
| #define array_count | ( | a | ) | ((a)->top) |
Definition at line 74 of file tessarray.h.
| #define array_free memfree |
Definition at line 83 of file tessarray.h.
| #define array_index | ( | a, | |
| i | |||
| ) | ((i<array_count(a)) ? (a)->base[i] : 0) |
Definition at line 93 of file tessarray.h.
| #define array_limit | ( | a | ) | ((a)->limit) |
Definition at line 103 of file tessarray.h.
| #define array_loop | ( | a, | |
| x | |||
| ) | for (x=0; x < array_count (a); x++) |
Definition at line 114 of file tessarray.h.
| #define array_top | ( | a | ) | ((a)->base[array_count (a) - 1]) |
Definition at line 123 of file tessarray.h.
| #define array_value | ( | a, | |
| i | |||
| ) | ((a)->base[i]) |
Definition at line 132 of file tessarray.h.
| #define DEFAULT_SIZE 2 |
Definition at line 66 of file tessarray.h.
| typedef struct array_record * ARRAY |
| typedef int(* intProc)() |
Definition at line 58 of file tessarray.h.
| typedef void(* voidProc)() |
Definition at line 56 of file tessarray.h.
Definition at line 53 of file tessarray.cpp.
{
int x;
array = array_push (array, NULL);
for (x = array_count (array) - 1; x > index; x--)
array_value (array, x) = array_value (array, x - 1);
array_value (array, index) = value;
return (array);
}
| ARRAY array_new | ( | int | num | ) |
Definition at line 70 of file tessarray.cpp.
{
ARRAY temp;
int x;
if (num == 0)
num = DEFAULT_SIZE;
temp = (ARRAY) memalloc ((num - 2) * sizeof (char *) +
sizeof (struct array_record));
if (!temp) {
cprintf ("error: Out of memory in array_new\n");
exit (1); //?err_exit ();
}
array_count (temp) = 0;
array_limit (temp) = num;
for (x = 0; x < num; x++)
array_value (temp, x) = (char *) 0;
return (temp);
}
Definition at line 98 of file tessarray.cpp.
{
if (array_count (array) == array_limit (array)) {
array = (ARRAY) memrealloc (array, (array_limit (array) * 2 - 2) *
sizeof (char *) +
sizeof (struct array_record),
(array_limit (array) -
2) * sizeof (char *) +
sizeof (struct array_record));
if (!array) {
cprintf ("error: Out of memory in array_push\n");
exit (1); //?err_exit ();
}
array_limit (array) *= 2;
}
array_count (array)++;
array_top (array) = value;
return (array);
}