Skip to content

Commit 32dab56

Browse files
authored
Merge pull request #243 from Flamefire/memLeak
Fix comparison and docu of generateCollectionType
2 parents 8773dc5 + 894e31a commit 32dab56

2 files changed

Lines changed: 13 additions & 10 deletions

File tree

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ env:
2020
script:
2121
- cd $BUILD
2222
# compile libSplash and install
23-
- cmake -DTOOLS_MPI=$SPLASHMPI $SRC
23+
- cmake -DCMAKE_BUILD_TYPE=Debug -DTOOLS_MPI=$SPLASHMPI $SRC
2424
- make package
2525
- sudo dpkg -i libsplash*.deb
2626
- ls -hal /usr/share/pyshared/
2727
- rm -rf $BUILD/*
2828
# compile examples/
29-
- cmake -DWITH_MPI=$SPLASHMPI $SRC/examples
29+
- cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_MPI=$SPLASHMPI $SRC/examples
3030
- make
3131
- rm -rf $BUILD/*
3232
# compile and run tests/
33-
- cmake -DWITH_MPI=$SPLASHMPI $SRC/tests
33+
- cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_MPI=$SPLASHMPI $SRC/tests
3434
- make
3535
# run tests
3636
- $SRC/tests/run_tests $BUILD

src/include/splash/basetypes/generateCollectionType.hpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2015 Carlchristian Eckert
2+
* Copyright 2015-2016 Carlchristian Eckert, Alexander Grund
33
*
44
* This file is part of libSplash.
55
*
@@ -32,7 +32,7 @@ namespace splash
3232

3333
/**
3434
* Checks if a datatype_id (from an outer scope) can be used to generate a
35-
* specific CollectionType derivate.
35+
* specific CollectionType instance.
3636
*
3737
* If the call to the genType member function of a specific collection type
3838
* is successful, it will return the pointer to an instance of this type.
@@ -43,7 +43,8 @@ namespace splash
4343
#define TRY_COLTYPE(_name) \
4444
{ \
4545
CollectionType* t = ColType##_name::genType(datatype_id); \
46-
if(t != NULL && typeid(*t) == typeid(ColType##_name)) return t; \
46+
assert(t == NULL || typeid(*t) == typeid(ColType##_name)); \
47+
if(t != NULL) return t; \
4748
} \
4849

4950

@@ -53,10 +54,11 @@ namespace splash
5354
* @param datatype_id the H5 datatype_id that should be converted into a
5455
* CollectionType
5556
*
56-
* @return A pointer to a heap-allocated CollectionType, if a matching
57-
* CollectionType could be determined. The allocated object must be
58-
* freed by the caller at the end of its lifetime.
59-
* If no matching CollectionType was found, returns NULL.
57+
* @return A pointer to a heap-allocated CollectionType.
58+
* The allocated object must be freed by the caller at the end of its
59+
* lifetime.
60+
* If no matching CollectionType was found, returns a ColTypeUnknown
61+
* instance.
6062
*/
6163
CollectionType* generateCollectionType(hid_t datatype_id)
6264
{
@@ -123,6 +125,7 @@ CollectionType* generateCollectionType(hid_t datatype_id)
123125
return new ColTypeUnknown;
124126
}
125127

128+
#undef TRY_COLTYPE
126129

127130
} /* namespace splash */
128131

0 commit comments

Comments
 (0)