Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
diff CircuitNetlistCreator.c @ 20:3a4be4048a21
missing changes committed
| author | hausers |
|---|---|
| date | Mon, 02 Apr 2012 14:06:11 +0200 |
| parents | ba3883d39e62 |
| children | fac65c465f98 |
line diff
1.1 --- a/CircuitNetlistCreator.c Fri Mar 02 18:14:06 2012 +0100 1.2 +++ b/CircuitNetlistCreator.c Mon Apr 02 14:06:11 2012 +0200 1.3 @@ -52,12 +52,14 @@ 1.4 1.5 netlist = malloc( sizeof(HWSimNetlist) ); 1.6 numElems= 2; 1.7 - elems = malloc( numElems * sizeof(HWSimElem) ); 1.8 + elems = malloc( numElems * sizeof(HWSimElem *) ); 1.9 netlist->numElems = numElems; 1.10 netlist->elems = elems; 1.11 netlist->numActivityTypes = 1; 1.12 netlist->activityTypes = malloc(netlist->numActivityTypes*sizeof(HWSimActivityType*)); 1.13 + // Stefan: tocheck valgrind 1.14 netlist->activityTypes[PING_PONG_TYPE] = createPingPongActivityType(); 1.15 + 1.16 elems[0] = createAPingPongElem( netlist ); //use info from netlist 1.17 elems[1] = createAPingPongElem( netlist ); 1.18 //on one of the elems, make reset trigger an action 1.19 @@ -75,7 +77,7 @@ 1.20 *The format is: sending TL-index, out-port, dest TL-index, in-port 1.21 */ 1.22 numCommPaths = 2; 1.23 - commPaths = malloc( numCommPaths * sizeof(HWSimCommPath) ); 1.24 + commPaths = malloc( numCommPaths * sizeof(HWSimCommPath *) ); 1.25 netlist->numCommPaths= numCommPaths; 1.26 netlist->commPaths= commPaths; 1.27 //TL 0, out-port 0 to TL 1, in-port 0 1.28 @@ -90,6 +92,24 @@ 1.29 1.30 return netlist; 1.31 } 1.32 + 1.33 +void 1.34 +freePingPongNetlist (HWSimNetlist *netlist) 1.35 +{ 1.36 + int i; 1.37 + for (i= 0; i<netlist->numCommPaths; i++) { 1.38 + free(netlist->commPaths[i]); 1.39 + } 1.40 + free(netlist->commPaths); 1.41 + for (i= 0; i<netlist->numElems; i++) { 1.42 + free(&netlist->elems[i]->inPorts[-1]); 1.43 + free(netlist->elems[i]); 1.44 + } 1.45 + 1.46 + free(netlist->activityTypes); 1.47 + free(netlist->elems); 1.48 + free(netlist); 1.49 +} 1.50 1.51 //Stefan: copy netlist struct with VMS malloc after VMS initialized? 1.52 //ANSWER: yes, otherwise the user has to deal with VMS details.
