- Timestamp:
- Oct 20, 2005, 8:47:25 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 2 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/RpUnits.cc
r104 r114 433 433 const RpUnits* to, 434 434 double (*convForwFxnPtr)(double), 435 double (*convBackFxnPtr)(double)) { 436 437 RpUnits* conv = new RpUnits( from, 438 to, 439 convForwFxnPtr, 440 convBackFxnPtr, 441 NULL, 442 NULL); 443 444 return conv; 435 double (*convBackFxnPtr)(double) ) { 436 437 // this is kinda the wrong way to get the job done... 438 // how do we only create 1 conversion object and share it between atleast two RpUnits 439 // objs so that when the RpUnits objs are deleted, we are not trying to delete already 440 // deleted memory. 441 // so for the sake of safety we get the following few lines of code. 442 443 conversion* conv1 = NULL; 444 conversion* conv2 = NULL; 445 446 conv1 = new conversion (from,to,convForwFxnPtr,convBackFxnPtr); 447 conv2 = new conversion (from,to,convForwFxnPtr,convBackFxnPtr); 448 449 from->connectConversion(conv1); 450 to->connectConversion(conv2); 451 452 return NULL; 445 453 } 446 454 … … 451 459 double (*convBackFxnPtr)(double,double)) { 452 460 453 RpUnits* conv = new RpUnits( from, 454 to, 455 convForwFxnPtr, 456 convBackFxnPtr, 457 NULL, 458 NULL); 459 460 return conv; 461 // this is kinda the wrong way to get the job done... 462 // how do we only create 1 conversion object and share it between atleast two RpUnits 463 // objs so that when the RpUnits objs are deleted, we are not trying to delete already 464 // deleted memory. 465 // so for the sake of safety we get the following few lines of code. 466 467 conversion* conv1 = NULL; 468 conversion* conv2 = NULL; 469 470 conv1 = new conversion (from,to,convForwFxnPtr,convBackFxnPtr); 471 conv2 = new conversion (from,to,convForwFxnPtr,convBackFxnPtr); 472 473 from->connectConversion(conv1); 474 to->connectConversion(conv2); 475 476 return NULL; 461 477 } 462 478 … … 469 485 void* convBackData) { 470 486 471 RpUnits* conv = new RpUnits( from, 472 to, 473 convForwFxnPtr, 474 convForwData, 475 convBackFxnPtr, 476 convBackData, 477 NULL, 478 NULL); 479 480 return conv; 487 // this is kinda the wrong way to get the job done... 488 // how do we only create 1 conversion object and share it between atleast two RpUnits 489 // objs so that when the RpUnits objs are deleted, we are not trying to delete already 490 // deleted memory. 491 // so for the sake of safety we get the following few lines of code. 492 493 conversion* conv1 = NULL; 494 conversion* conv2 = NULL; 495 496 conv1 = new conversion (from,to,convForwFxnPtr,convForwData,convBackFxnPtr,convBackData); 497 conv2 = new conversion (from,to,convForwFxnPtr,convForwData,convBackFxnPtr,convBackData); 498 499 from->connectConversion(conv1); 500 to->connectConversion(conv2); 501 502 return NULL; 481 503 } 482 504 … … 630 652 const RpUnits* basis = getBasis(); 631 653 double retVal = *value; 632 int convResult = 0;654 int convResult = 1; 633 655 634 656 if (basis == NULL) { … … 644 666 } 645 667 646 if ( (convResult == 1) ) {668 if ( (convResult == 0) ) { 647 669 *value = retVal; 648 670 } … … 1206 1228 // check if the list was created previously. if not, start the list 1207 1229 if (head == 0) { 1208 head = new unit(units,exponent,basis,NULL );1230 head = new unit(units,exponent,basis,NULL,NULL); 1209 1231 return; 1210 1232 } 1211 1233 1212 1234 // now add a new node at the beginning of the list: 1213 p = new unit(units,exponent,basis, head);1235 p = new unit(units,exponent,basis,NULL,head); 1214 1236 head->prev = p; 1215 1237 head = p; … … 1343 1365 1344 1366 1345 void 1346 RpUnits::connectConversion(con st RpUnits* myRpUnit){1347 1348 convEntry* p = myRpUnit->convList;1367 void 1368 RpUnits::connectConversion(conversion* conv) const { 1369 1370 convEntry* p = convList; 1349 1371 1350 1372 if (p == NULL) { 1351 myRpUnit->convList = new convEntry (this->conv,NULL,NULL);1373 convList = new convEntry (conv,NULL,NULL); 1352 1374 } 1353 1375 else { … … 1356 1378 } 1357 1379 1358 p->next = new convEntry ( this->conv,p,NULL);1380 p->next = new convEntry (conv,p,NULL); 1359 1381 } 1360 1382 … … 1363 1385 // return codes: 0 success, anything else is error 1364 1386 int 1365 RpUnits::addPresets ( std::string group) {1387 RpUnits::addPresets (const std::string group) { 1366 1388 int retVal = -1; 1367 1389 if (group.compare("all") == 0) {
Note: See TracChangeset
for help on using the changeset viewer.