summaryrefslogtreecommitdiff
path: root/src/main/ActiveThorns.c
diff options
context:
space:
mode:
authortradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-02-02 17:22:42 +0000
committertradke <tradke@17b73243-c579-4c4c-a9d2-2d5706c11dac>2000-02-02 17:22:42 +0000
commitefe1846d2629923afbcf138958d81d0eeb622631 (patch)
tree3a871be63f9040e81ae56f07f883577b90f5ec03 /src/main/ActiveThorns.c
parente4e8dc2d6f14243518766db4327f2e33504ad304 (diff)
Removed routines that allocated and returned a list of thorns or implementations.
Instead you can use now: int CCTK_NumCompiledThorns(void); int CCTK_NumCompiledImplementations(void); const char *CCTK_CompiledThorn(int index); const char *CCTK_CompiledImplementation(int index); Will probably add also CCTK_CompiledThornWalk() and CCTK_CompiledImplementationWalk() later. Thomas git-svn-id: http://svn.cactuscode.org/flesh/trunk@1335 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main/ActiveThorns.c')
-rw-r--r--src/main/ActiveThorns.c251
1 files changed, 94 insertions, 157 deletions
diff --git a/src/main/ActiveThorns.c b/src/main/ActiveThorns.c
index f669665f..d78eab65 100644
--- a/src/main/ActiveThorns.c
+++ b/src/main/ActiveThorns.c
@@ -560,12 +560,13 @@ int CCTKi_PrintImps(FILE *file, const char *format, int active)
return retval;
}
+
/*@@
- @routine CCTKi_ImplementationList
- @date Thu Oct 14 16:14:22 1999
- @author Andre Merzky
+ @routine CCTK_ActivatingThorn
+ @date Thu Oct 14 16:08:42 1999
+ @author Tom Goodale
@desc
- Returns the list of implementations.
+ Finds the thorn which activated a particular implementation
@enddesc
@calls
@calledby
@@ -574,29 +575,26 @@ int CCTKi_PrintImps(FILE *file, const char *format, int active)
@endhistory
@@*/
-int CCTKi_ImplementationList(int active, char ***list, int *n_implementations)
+const char *CCTK_ActivatingThorn(const char *name)
{
- int retval;
- t_sktree *node;
+ const char *retval;
+ t_sktree *node;
+
struct IMPLEMENTATION *imp;
- retval = 0;
+ /* Find the implementation */
+ node = SKTreeFindNode(implist, name);
+ retval = NULL;
- *list = (char **)malloc(n_imps*sizeof(char *));
-
- for(node= SKTreeFindFirst(implist), *n_implementations = 0;
- node;
- node = node->next, retval++)
+ if(node)
{
imp = (struct IMPLEMENTATION *)(node->data);
- if(imp->active || !active)
+ if(imp->active)
{
- (*list)[*n_implementations] = (char *) malloc(strlen(node->key)+1);
- strcpy((*list)[*n_implementations], node->key);
- (*n_implementations)++;
+ retval = imp->activating_thorn;
}
}
@@ -604,12 +602,14 @@ int CCTKi_ImplementationList(int active, char ***list, int *n_implementations)
}
+
/*@@
- @routine CCTKi_ThornList
- @date Sun Oct 17 17:49:23 1999
+ @routine CCTK_ImpThornList
+ @date Tue Jul 27 09:15:58 1999
@author Tom Goodale
@desc
- Returns the list of thorns.
+ Return the thorns for an implementation.
+ For now return an sktree - FIXME
@enddesc
@calls
@calledby
@@ -618,30 +618,27 @@ int CCTKi_ImplementationList(int active, char ***list, int *n_implementations)
@endhistory
@@*/
-int CCTKi_ThornList(int active, char ***list, int *n_items)
+t_sktree *CCTK_ImpThornList(const char *name)
{
- int retval;
- t_sktree *node;
+ t_sktree *retval;
- struct THORN *thorn;
+ t_sktree *node;
+
+ struct IMPLEMENTATION *imp;
+
- retval = 0;
+ /* Find the implementation */
+ node = SKTreeFindNode(implist, name);
- *list = (char **)malloc(n_thorns*sizeof(char *));
-
- for(node= SKTreeFindFirst(thornlist),
- *n_items = 0;
- node;
- node = node->next, retval++)
+ if(node)
{
- thorn = (struct THORN *)(node->data);
+ imp = (struct IMPLEMENTATION *)(node->data);
- if(thorn->active || !active)
- {
- (*list)[*n_items] = (char *) malloc(strlen(node->key)+1);
- strcpy((*list)[*n_items], node->key);
- (*n_items)++;
- }
+ retval = imp->thornlist;
+ }
+ else
+ {
+ retval = NULL;
}
return retval;
@@ -649,101 +646,31 @@ int CCTKi_ThornList(int active, char ***list, int *n_items)
/*@@
- @routine CCTKi_ImplementationThornList
- @date Thu Oct 14 16:04:59 1999
- @author Andre Merzky
+ @routine CCTK_NumCompiledThorns
+ @date Tue Feb 02 2000
+ @author Thomas Radke
@desc
- Returns a list of thorns.
+ Return the number of thorns compiled in.
@enddesc
@calls
@calledby
@history
-
+
@endhistory
@@*/
-int CCTKi_ImplementationThornList (const char *imp, char ***list, int *n_items)
+int CCTK_NumCompiledThorns(void)
{
- int retval;
- t_sktree *node;
- t_sktree *thornlist;
- int alloc_size = 0;
-
- /* FIXME */
-#define _MY_THORN_JUNK_SIZE 10
-
-
- retval = 0;
-
- /* find all thorns for implementation */
- thornlist = (t_sktree*) CCTK_ImpThornList (imp);
-
-
- /* got thornlist? */
- if (thornlist)
- {
- /* then we can start allocatin list */
- alloc_size += _MY_THORN_JUNK_SIZE;
- *list = (char **) malloc (alloc_size * sizeof (char *));
-
- /* success? */
- if (! (*list))
- {
- fprintf (stderr, "Cannot malloc paramlist*\n");
- return (-1);
- }
- /* recourse thorn tree */
- for (node = SKTreeFindFirst (thornlist),
- *n_items = 0;
- node;
- node = node->next, retval++)
- {
- /* list long enough? */
- if ((*n_items) >= alloc_size)
- {
- /* no: realloc! */
- alloc_size += _MY_THORN_JUNK_SIZE;
- *list = (char **) realloc ((*list), alloc_size);
-
- /* success? */
- if (! (*list)) {
- fprintf (stderr, "Cannot realloc paramlist*\n");
- return (-1);
- }
-
- }
-
- /* store thorn */
- (*list)[*n_items] = (char *) malloc ((strlen (node->key) + 1) * sizeof (char));
- strcpy ((*list)[*n_items], node->key);
- (*n_items)++;
- }
- }
-
- /* if necessary, shrink paramlist again. */
- if ((*n_items) < alloc_size)
- {
- alloc_size += (*n_items);
- *list = (char **) realloc ((*list), alloc_size);
-
- if (! (*list))
- {
- fprintf (stderr, "Cannot realloc list*\n");
- return (-1);
- }
- }
-
- /* done */
- return retval;
+ return n_thorns;
}
-
+
/*@@
- @routine CCTK_ActivatingThorn
- @date Thu Oct 14 16:08:42 1999
- @author Tom Goodale
+ @routine CCTK_CompiledThorn
+ @date Tue Feb 02 2000
+ @author Thomas Radke
@desc
- Finds the thorn which activated a particular implementation
+ Return the name of the compiled thorn with given index.
@enddesc
@calls
@calledby
@@ -752,41 +679,35 @@ int CCTKi_ImplementationThornList (const char *imp, char ***list, int *n_items)
@endhistory
@@*/
-const char *CCTK_ActivatingThorn(const char *name)
+const char *CCTK_CompiledThorn(int index)
{
- const char *retval;
-
+ int i;
t_sktree *node;
-
- struct IMPLEMENTATION *imp;
+ const char *ret_val;
- /* Find the implementation */
- node = SKTreeFindNode(implist, name);
+ ret_val = NULL;
- retval = NULL;
-
- if(node)
+ for(node = SKTreeFindFirst(thornlist), i = 0;
+ node;
+ node = node->next, i++)
{
- imp = (struct IMPLEMENTATION *)(node->data);
-
- if(imp->active)
+ if (i == index)
{
- retval = imp->activating_thorn;
+ ret_val = node->key;
+ break;
}
}
- return retval;
+ return ret_val;
}
-
-
+
/*@@
- @routine CCTK_ImpThornList
- @date Tue Jul 27 09:15:58 1999
- @author Tom Goodale
+ @routine CCTK_NumCompiledImplementations
+ @date Tue Feb 02 2000
+ @author Thomas Radke
@desc
- Return the thorns for an implementation.
- For now return an sktree - FIXME
+ Return the number of implementations compiled in.
@enddesc
@calls
@calledby
@@ -795,28 +716,44 @@ const char *CCTK_ActivatingThorn(const char *name)
@endhistory
@@*/
-t_sktree *CCTK_ImpThornList(const char *name)
+int CCTK_NumCompiledImplementations(void)
{
- t_sktree *retval;
+ return n_imps;
+}
- t_sktree *node;
-
- struct IMPLEMENTATION *imp;
+ /*@@
+ @routine CCTK_CompiledImplementation
+ @date Tue Feb 02 2000
+ @author Thomas Radke
+ @desc
+ Return the name of the compiled implementation with given index.
+ @enddesc
+ @calls
+ @calledby
+ @history
+
+ @endhistory
- /* Find the implementation */
- node = SKTreeFindNode(implist, name);
+@@*/
+const char *CCTK_CompiledImplementation(int index)
+{
+ int i;
+ t_sktree *node;
+ const char *ret_val;
- if(node)
- {
- imp = (struct IMPLEMENTATION *)(node->data);
+ ret_val = NULL;
- retval = imp->thornlist;
- }
- else
+ for(node = SKTreeFindFirst(implist), i = 0;
+ node;
+ node = node->next, i++)
{
- retval = NULL;
+ if (i == index)
+ {
+ ret_val = node->key;
+ break;
+ }
}
- return retval;
+ return ret_val;
}