Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5659 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Nov 20, 2005, 11:31:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: valgrind sweep - no more Use of Uninitialized Value in MultiType

Location:
trunk/src/lib/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor.cc

    r5641 r5659  
    5959  // What Parameters we have got
    6060  for (unsigned int i = 0; i < paramCount; i++)
    61     this->defaultValue[i].setType(va_arg(parameterList, int));
     61  {
     62    int type = va_arg(parameterList, int);
     63    this->defaultValue[i].setType(type);
     64  }
    6265}
    6366
     
    7982  executor->defaultValue = new MultiType[this->paramCount];
    8083  for (unsigned int i = 0; i < this->paramCount; i++)
    81     executor->defaultValue[i] = this->defaultValue[i];
     84  {
     85    executor->defaultValue[i] =  this->defaultValue[i];
     86//    printf("1: %s 2: %s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType()),  MultiType::MultiTypeToString(executor->defaultValue[i].getType()));
     87  }
    8288}
    8389
  • trunk/src/lib/util/executor/executor_specials.h

    r5652 r5659  
    2828     */
    2929    ExecutorXML(void(T::*function)(const TiXmlElement*), const TiXmlElement* root, const char* paramName)
    30       : Executor(1)
     30      : Executor(1, MT_EXT1)
    3131    {
    3232      PRINTF(4)("Loading %s from XML-element %p\n", paramName, root);
  • trunk/src/lib/util/multi_type.cc

    r5643 r5659  
    1717
    1818#include "multi_type.h"
    19 #include "stdincl.h"
    20 // #include <stddef.h>
    21 // #include <stdlib.h>
    22 // #include <string.h>
    23 // #include <stdio.h>
     19
     20//#include "stdincl.h"
     21#include <stddef.h>
     22#include <stdlib.h>
     23#include <string.h>
     24#include <stdio.h>
     25
     26#ifdef DEBUG
     27#include "debug.h"
     28#endif
    2429
    2530using namespace std;
     
    8085  this->init();
    8186  this->setString(value);
     87}
     88
     89MultiType::MultiType(const MultiType& multiType)
     90{
     91  this->init();
     92  printf("test2");
     93  *this = multiType;
    8294}
    8395
     
    96108 * @returns a Copy of itself. (strings inside are copied as well)
    97109 */
    98 // MultiType MultiType::operator= (const MultiType& mt)
    99 // {
    100 //   this->type = mt.type;
    101 //   this->value = mt.value;
    102 //
    103 //   if (mt.type == MT_STRING && mt.storedString != NULL)
    104 //   {
    105 //     this->storedString = new char[strlen (mt.storedString)+1];
    106 //     strcpy(this->storedString, mt.storedString);
    107 //     this->value.String = this->storedString;
    108 //   }
    109 //   else
    110 //     this->storedString = NULL;
    111 //   return *this;
    112 // }
     110MultiType& MultiType::operator= (const MultiType& mt)
     111{
     112  this->type = mt.type;
     113  this->value = mt.value;
     114
     115  printf("test\n");
     116  if (mt.type == MT_STRING && mt.storedString != NULL)
     117  {
     118    this->setString(mt.storedString);
     119  }
     120  else
     121    this->storedString = NULL;
     122  return *this;
     123}
    113124
    114125/**
     
    119130  this->type = MT_NULL;
    120131  this->storedString = NULL;
    121   this->value.Bool = false;
     132  this->value.Float = 0.0f;
    122133}
    123134
     
    130141{
    131142  if (this->type != type)
    132   {
    133143    this->type = (MT_Type)type;
    134 
    135     if (this->type == MT_NULL)
    136       this->reset();
    137   }
    138144}
    139145
     
    336342void MultiType::debug()
    337343{
    338   printf("MultiType of Type: %s is: BOOL: %d, INT: %d, FLOAT: %f, CHAR: %c, STRING %s\n",
     344#ifdef DEBUG
     345  PRINT(0)
     346#else
     347  printf
     348#endif
     349      ("MultiType of Type '%s' :: Values: BOOL: '%d', INT: '%d', FLOAT: '%f', CHAR: '%c', STRING '%s'\n",
    339350         MultiType::MultiTypeToString(this->type),
    340351         this->getBool(),
     
    343354         this->getChar(),
    344355         this->getString()
    345   );
     356      );
    346357
    347358
     
    353364void MultiType::reset()
    354365{
    355   switch (this->type)
    356   {
    357     default:
    358       break;
     366  switch ( this->type )
     367  {
    359368    case MT_BOOL:
    360369      this->setBool(false);
     
    371380      this->setString("");
    372381      break;
     382    default:
     383#ifdef DEBUG
     384      PRINTF(2)("Unknown Type not reseting\n");
     385#endif
     386      break;
    373387  }
    374388}
     
    381395const char* MultiType::MultiTypeToString(MT_Type type)
    382396{
    383   switch (type)
     397  switch ( type )
    384398  {
    385399   default:
  • trunk/src/lib/util/multi_type.h

    r5644 r5659  
    3939    MultiType(char value);
    4040    MultiType(const char* value);
     41    MultiType(const MultiType& multiType);
    4142    virtual ~MultiType();
    4243
    43 //    MultiType operator= (const MultiType& mt);
     44    MultiType& operator= (const MultiType& mt);
    4445
    4546    void setType(int type);
     
    8081
    8182  private:
    82     MT_Type             type;
     83
    8384    union MultiTypeValue
    8485    {
     
    9192    }                   value;
    9293
     94    MT_Type             type;
     95
    9396    char*               storedString;
    9497};
Note: See TracChangeset for help on using the changeset viewer.