issue 693: add missing release call in c-export interface.

pull/696/head
Kim Kulling 2015-11-23 21:28:35 +01:00
parent e6ac1ed66a
commit 70540616ce
2 changed files with 35 additions and 4 deletions

View File

@ -59,13 +59,37 @@ ASSIMP_API size_t aiGetExportFormatCount(void)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex) ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index)
{ {
// Note: this is valid as the index always pertains to a builtin exporter, // Note: this is valid as the index always pertains to a built-in exporter,
// for which the returned structure is guaranteed to be of static storage duration. // for which the returned structure is guaranteed to be of static storage duration.
return Exporter().GetExportFormatDescription(pIndex); const aiExportFormatDesc* orig( Exporter().GetExportFormatDescription( index ) );
if (NULL == orig) {
return NULL;
}
aiExportFormatDesc *desc = new aiExportFormatDesc;
desc->description = new char[ strlen( orig->description ) + 1 ];
::strncpy( (char*) desc->description, orig->description, strlen( orig->description ) );
desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ];
::strncpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) );
desc->id = new char[ strlen( orig->id ) + 1 ];
::strncpy( ( char* ) desc->id, orig->id, strlen( orig->id ) );
return desc;
} }
// ------------------------------------------------------------------------------------------------
ASSIMP_API void aiReleaseExportFormatDescription( const aiExportFormatDesc *desc ) {
if (NULL == desc) {
return;
}
delete [] desc->description;
delete [] desc->fileExtension;
delete [] desc->id;
delete desc;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut) ASSIMP_API void aiCopyScene(const aiScene* pIn, aiScene** pOut)

View File

@ -86,13 +86,20 @@ ASSIMP_API size_t aiGetExportFormatCount(void);
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
/** Returns a description of the nth export file format. Use #aiGetExportFormatCount() /** Returns a description of the nth export file format. Use #aiGetExportFormatCount()
* to learn how many export formats are supported. * to learn how many export formats are supported. The description must be released by
* calling aiReleaseExportFormatDescription afterwards.
* @param pIndex Index of the export format to retrieve information for. Valid range is * @param pIndex Index of the export format to retrieve information for. Valid range is
* 0 to #aiGetExportFormatCount() * 0 to #aiGetExportFormatCount()
* @return A description of that specific export format. NULL if pIndex is out of range. * @return A description of that specific export format. NULL if pIndex is out of range.
*/ */
ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex); ASSIMP_API const C_STRUCT aiExportFormatDesc* aiGetExportFormatDescription( size_t pIndex);
// --------------------------------------------------------------------------------
/** Release a description of the nth export file format. Must be returned by
* aiGetExportFormatDescription
* @param desc Pointer to the description
*/
ASSIMP_API void aiReleaseExportFormatDescription( const C_STRUCT aiExportFormatDesc *desc );
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
/** Create a modifiable copy of a scene. /** Create a modifiable copy of a scene.