summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1998-09-29 10:17:37 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1998-09-29 10:17:37 +0000
commitc319a69c421f784770e26a6db303b86a0c125e0f (patch)
tree2ffc438208e36020c50303fe83ffe1c36900c179 /src/util
parent52e0948990bb26f3e90efa54bb5d275a981d21b8 (diff)
Added a function to create a keyd function array.
git-svn-id: http://svn.cactuscode.org/flesh/trunk@12 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util')
-rw-r--r--src/util/RegisterKeyedFunction.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/util/RegisterKeyedFunction.c b/src/util/RegisterKeyedFunction.c
index cda2a5a2..10e42ad7 100644
--- a/src/util/RegisterKeyedFunction.c
+++ b/src/util/RegisterKeyedFunction.c
@@ -52,10 +52,50 @@ int RegisterKeyedFunction(void (*array[])(),
return return_code;
}
+ /*@@
+ @routine CreateKeyedFunctionArray
+ @date Tue Sep 29 11:16:51 1998
+ @author Tom Goodale
+ @desc
+
+ This creates a keyed function array and initialises it to NULL.
+
+ Function which returns a pointer to a pointer to a function which returns void.
+ (An array of pointers to functions which return void.
+
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
+
+@@*/
+void (**(CreateKeyedFunctionArray(int size)))()
+{
+ void (**array)();
+ int i;
+
+ /* Allocate the memory. */
+ array = (void (**)())malloc(size*sizeof(void (*)()));
+
+ if(array)
+ {
+ /* Initialise the data. */
+ for(i = 0; i < size; i++)
+ {
+ array[i] = NULL;
+ };
+ };
+
+ return array;
+}
+
+
#ifdef TEST_KEYED_FUNCTIONS
-static void (*functions[])() = {NULL, NULL, NULL};
+static void (**functions)();
void RegisterTestFunction(int key, void (*func)())
{
@@ -87,6 +127,16 @@ int main(int argc, char *argv[])
int i;
void (*test)();
+ functions = CreateKeyedFunctionArray(3);
+
+ if(!functions)
+ {
+ fprintf(stderr, "Function array is still null !\n");
+
+ exit(1);
+ };
+
+
REGTEST(0);
REGTEST(1);
REGTEST(2);