Jump to content
Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  
Evil Steve


I've been tasked with some tools work at work, and I've come across a few juicy code snippets I'd like to share.

There's so many things wrong with these that I can't even be bothered listing what they are.

First, a simple memory leak:

blUtilFindFilesResult * textureBatchFile = new blUtilFindFilesResult( source , target );
textureDirSet.insert( *textureBatchFile );

Next, an "interesting" way to skip over the "." and ".." directories returned by FindNextFile:

hFindFile = FindFirstFile(inputDirFilename.c_str(), &fileData);
char * test;
if (!(hFindFile == INVALID_HANDLE_VALUE))
test = fileData.cFileName;
FindNextFile( hFindFile, &fileData);
while ( FindNextFile( hFindFile, &fileData) != 0)
test =fileData.cFileName ;
inputFileList.append(" ");

And finally:

static char * getDirName( const char * _pInputName, char * _pDirName )

size_t fileNameLength = strlen(_pInputName);
char * filename = ( char* )malloc(fileNameLength+10);
strcpy( filename , _pInputName);
int dirLength;
for( int i = fileNameLength; i > 0; i-- )
if( filename == '\\' )
filename[i +1] = '*';
filename[i +2] = '\0';
dirLength = i+1;
_pDirName = (char * )malloc( dirLength + 20 );
strcpy( _pDirName , filename);
_pDirName[dirLength] ='\0';

return _pDirName;


Oh god.

Back to getting rid of the crap...
Sign in to follow this  


Recommended Comments

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!