diff --git a/src/lib/openjp2/cio.c b/src/lib/openjp2/cio.c index f7f1bc72..bf91371c 100644 --- a/src/lib/openjp2/cio.c +++ b/src/lib/openjp2/cio.c @@ -246,7 +246,15 @@ void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, opj_strea l_stream->m_skip_fn = p_function; } -void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function) +void OPJ_CALLCONV opj_stream_set_user_data(opj_stream_t* p_stream, void * p_data) +{ + opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; + if (!l_stream) + return; + l_stream->m_user_data = p_data; +} + +void OPJ_CALLCONV opj_stream_set_user_data_v3(opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function) { opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream; if (!l_stream) diff --git a/src/lib/openjp2/openjpeg.c b/src/lib/openjp2/openjpeg.c index 0522acb0..dfb8093c 100644 --- a/src/lib/openjp2/openjpeg.c +++ b/src/lib/openjp2/openjpeg.c @@ -944,7 +944,7 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v3 ( return NULL; } - opj_stream_set_user_data(l_stream, p_file, (opj_stream_free_user_data_fn) fclose); + opj_stream_set_user_data_v3(l_stream, p_file, (opj_stream_free_user_data_fn) fclose); opj_stream_set_user_data_length(l_stream, opj_get_data_length_from_file(p_file)); opj_stream_set_read_function(l_stream, (opj_stream_read_fn) opj_read_from_file); opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file); diff --git a/src/lib/openjp2/openjpeg.h b/src/lib/openjp2/openjpeg.h index 1ea2af80..466d07fd 100644 --- a/src/lib/openjp2/openjpeg.h +++ b/src/lib/openjp2/openjpeg.h @@ -1067,13 +1067,21 @@ OPJ_API void OPJ_CALLCONV opj_stream_set_skip_function(opj_stream_t* p_stream, o */ OPJ_API void OPJ_CALLCONV opj_stream_set_seek_function(opj_stream_t* p_stream, opj_stream_seek_fn p_function); +/** + * Sets the given data to be used as a user data for the stream. + * @param p_stream the stream to modify + * @param p_data the data to set. + * @warning depending on your source object p_stream this function may leak, use opj_stream_set_user_data_v3 +*/ +OPJ_DEPRECATED(OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data)); + /** * Sets the given data to be used as a user data for the stream. * @param p_stream the stream to modify * @param p_data the data to set. * @param p_function the function to free p_data when opj_stream_destroy() is called. */ -OPJ_API void OPJ_CALLCONV opj_stream_set_user_data (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function); +OPJ_API void OPJ_CALLCONV opj_stream_set_user_data_v3 (opj_stream_t* p_stream, void * p_data, opj_stream_free_user_data_fn p_function); /** * Sets the length of the user data for the stream.