[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

tests & shared libraries



--

After the changes to PenguinSound to use the PenguinPlay Debug and
Exception stuff
I found a few flaws. I get warning messages about the comma operator
with each use of ppDebug1 in the code if I don't have PP_DEBUGLEVEL >= 4 
#define ppDebug1 (void) doesn't cut it

Correct me if I'm wrong but wouldn't that turn 

ppDebug1("text %s", "more text");

into 

(void)("text %s", "more text"); 
 
I can get rid of it by using

inline void  ppDebug(const char*, ...) {} 

instead of the define, but I'm not sure that that is a good thing to do.

--

I decided to move the tests in PenguinSound to a separate directory
"src/tests"
and use libpenguinplay.so instead of the static library. Doing that I
found that 
_ppDebug etc need to have a PP_EXTC prepended to it in ppUtils.cpp

There is also a bit of a mixup between the VirtWrite prototype and its
implementation. The prototype uses a const void* buffer as a parameter
but the implementation uses only a void* buffer. There were no warning
messsages about this.
I changed it to a const in the implemenation and then hunted down all
the other write functions that VirtWrite used that should be using a
const void * buffer instead of void*.

When I finally built the test I found that it segfaulted in PenguinFile.
I thought that was a bit funny since the test didn't use PenguinFile. I
had some trouble getting gdb to debug it since it was using a shared
library that wasn't installed so I gave in to the tempatation and ran
make install. I tracked the debug down to the instantiation of a global
variable in PenguinFile. The global variable is  FileTGlobalData
FileGlobalData; and it is defined in FileGlobalData
a void* . FileGlobalData is a singleton. There are better ways to
implement singletons. Take a look at my RegistryFactory for the way I
did it.

Instead of creating a separate global variable give FileTGlobalData a
method to 
retrieve an instance of itself. Make the constructor private. Then the
variable won't be created at startup. It won't be created until it is
needed.

The bad memory access was at  Directory::Misc::GetHashOf.

Peter Burns