[trunk] Rework previous commit r2610

This way we are able to gently deprecate the old API, and preserve ABI
Update issue 306
This commit is contained in:
Mathieu Malaterre 2014-03-25 10:23:40 +00:00
parent 2b93727bea
commit 492d8ab7d9
3 changed files with 19 additions and 3 deletions

View File

@ -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; 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; opj_stream_private_t* l_stream = (opj_stream_private_t*) p_stream;
if (!l_stream) if (!l_stream)

View File

@ -944,7 +944,7 @@ opj_stream_t* OPJ_CALLCONV opj_stream_create_file_stream_v3 (
return NULL; 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_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_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); opj_stream_set_write_function(l_stream, (opj_stream_write_fn) opj_write_from_file);

View File

@ -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); 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. * Sets the given data to be used as a user data for the stream.
* @param p_stream the stream to modify * @param p_stream the stream to modify
* @param p_data the data to set. * @param p_data the data to set.
* @param p_function the function to free p_data when opj_stream_destroy() is called. * @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. * Sets the length of the user data for the stream.