Skip to content

Commit

Permalink
Add a function to free allocated memory (#52)
Browse files Browse the repository at this point in the history
Managed runtimes like C# P/Invoke requires this in order to be able to
correctly free memory in managed code that was allocated by unmanaged
code.

The method was only defined in copentime because it can be used on it's
own but opentimlineio must be used with opentime.

Signed-off-by: Félix Bourbonnais <[email protected]>
  • Loading branch information
BadSingleton authored May 12, 2023
1 parent 3ba531c commit 832b92a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/copentime/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ inline opentime::TimeTransform CTimeTransform_to_CppTimeTransform(TimeTransform
opentime::RationalTime offset = CRationalTime_to_CppRationalTime(timeTransform.offset);
return opentime::TimeTransform(offset, timeTransform.scale, timeTransform.rate);
}

OTIO_API void Opentime_Free(void *ptr);
1 change: 1 addition & 0 deletions src/copentime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ add_library(copentime ${COTIO_SHARED_OR_STATIC_LIB}
timeRange.cpp
timeTransform.cpp
optionalOpenTime.cpp
util.cpp
${PROJECT_SOURCE_DIR}/include/copentime/util.h
${COPENTIME_HEADER_FILES})

Expand Down
8 changes: 8 additions & 0 deletions src/copentime/util.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project

#include "copentime/util.h"

OTIO_API void Opentime_Free(void *ptr){
free(ptr);
}

0 comments on commit 832b92a

Please sign in to comment.