/[escript]/trunk/escript/src/blocktimer.c
ViewVC logotype

Diff of /trunk/escript/src/blocktimer.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1388 by trankine, Fri Jan 11 07:45:58 2008 UTC revision 1644 by phornby, Tue Jul 15 05:25:32 2008 UTC
# Line 11  Line 11 
11  #endif  #endif
12    
13  #include "escript/blocktimer.h"  #include "escript/blocktimer.h"
14    #include "malloc.h"
15    #include "string.h"
16    
17  #ifdef PASO_MPI  #ifdef PASO_MPI
18  #include "mpi.h"  #include "mpi.h"
# Line 54  blocktimer_initialize() Line 56  blocktimer_initialize()
56  }  }
57    
58  void  void
59  blocktimer_increment(char *name, double start_time)  blocktimer_increment(__const char *name, double start_time)
60  {  {
61  #ifdef BLOCKTIMER  #ifdef BLOCKTIMER
62    int id;    int id;
# Line 69  blocktimer_increment(char *name, double Line 71  blocktimer_increment(char *name, double
71  }  }
72    
73  int  int
74  blocktimer_getOrCreateTimerId(char *name)  blocktimer_getOrCreateTimerId(__const char *name)
75  {  {
76    int id=0;    int id=0;
77  #ifdef BLOCKTIMER  #ifdef BLOCKTIMER
78      char *tmp_str;
79    static int nextId = 0;        /* Next timer ID to assign */    static int nextId = 0;        /* Next timer ID to assign */
80    ENTRY item, *found_item;    ENTRY item, *found_item;
81    
82    if (!g_initialized) { return(0); }    if (!g_initialized) { return(0); }
83    
84    /* Has a timer with 'name' already been defined? */    /* Has a timer with 'name' already been defined? */
85    item.key = name;    item.key = (char *)name;
86    item.data = (void *) NULL;    item.data = (void *) NULL;
87    found_item = hsearch(item, FIND);    found_item = hsearch(item, FIND);
88    
# Line 97  blocktimer_getOrCreateTimerId(char *name Line 100  blocktimer_getOrCreateTimerId(char *name
100        exit(1);        exit(1);
101      }      }
102      *idTmp = nextId++;      *idTmp = nextId++;
103      item.key = name;      item.key = (char *)name;
104      item.data = (void *) idTmp;      item.data = (void *) idTmp;
105      hsearch(item, ENTER);      hsearch(item, ENTER);
106      id = *idTmp;      id = *idTmp;
107      g_names[id] = (char *)strdup(name);      /* Make a copy of the name and save with other names */
108        tmp_str = malloc(strlen(name)+1);
109        strcpy(tmp_str, name);
110        g_names[id] = tmp_str;
111    }    }
112    
113  #endif /* BLOCKTIMER */  #endif /* BLOCKTIMER */

Legend:
Removed from v.1388  
changed lines
  Added in v.1644

  ViewVC Help
Powered by ViewVC 1.1.26