diff options
author | dcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db> | 2011-05-24 16:52:47 +0000 |
---|---|---|
committer | dcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db> | 2011-05-24 16:52:47 +0000 |
commit | 22a3a4d3c797a86128978698ff732fbc781d626a (patch) | |
tree | 25e4687068699d56c44b5016cd9288c700eb26a3 /turbojpeg.h | |
parent | 582cefc2354ea9c206bc80887533fed36770b2a2 (diff) |
Add new API functions, tjAlloc() and tjFree(), which allow memory to be allocated and freed using a method of the library's choosing. At the moment, the primary purpose for this is to avoid allocating/freeing memory across the DLL boundary on Windows.
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@634 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'turbojpeg.h')
-rw-r--r-- | turbojpeg.h | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/turbojpeg.h b/turbojpeg.h index 17bc306..f685547 100644 --- a/turbojpeg.h +++ b/turbojpeg.h @@ -432,8 +432,8 @@ DLLEXPORT tjhandle DLLCALL tjInitCompress(void); * @param jpegBuf address of a pointer to an image buffer that will receive the * JPEG image. TurboJPEG has the ability to reallocate the JPEG buffer * to accommodate the size of the JPEG image. Thus, you can choose to: - * -# pre-allocate the JPEG buffer with an arbitrary size and let - * TurboJPEG grow the buffer as needed, + * -# pre-allocate the JPEG buffer with an arbitrary size using + * #tjAlloc() and let TurboJPEG grow the buffer as needed, * -# set <tt>*jpegBuf</tt> to NULL to tell TurboJPEG to allocate the * buffer for you, or * -# pre-allocate the buffer to a "worst case" size determined by @@ -683,8 +683,8 @@ DLLEXPORT tjhandle DLLCALL tjInitTransform(void); * parameters in <tt>transforms[i]</tt>. TurboJPEG has the ability to * reallocate the JPEG buffer to accommodate the size of the JPEG image. * Thus, you can choose to: - * -# pre-allocate the JPEG buffer with an arbitrary size and let - * TurboJPEG grow the buffer as needed, + * -# pre-allocate the JPEG buffer with an arbitrary size using + * #tjAlloc() and let TurboJPEG grow the buffer as needed, * -# set <tt>dstBufs[i]</tt> to NULL to tell TurboJPEG to allocate the * buffer for you, or * -# pre-allocate the buffer to a "worst case" size determined by @@ -727,6 +727,31 @@ DLLEXPORT int DLLCALL tjDestroy(tjhandle handle); /** + * Allocate an image buffer for use with TurboJPEG. You should always use + * this function to allocate the JPEG destination buffer(s) for #tjCompress2() + * and #tjTransform() unless you are disabling automatic buffer + * (re)allocation (by setting #TJFLAG_NOREALLOC.) + * + * @param bytes the number of bytes to allocate + * + * @return a pointer to a newly-allocated buffer with the specified number of + * bytes + */ +DLLEXPORT unsigned char* DLLCALL tjAlloc(int bytes); + + +/** + * Free an image buffer previously allocated by TurboJPEG. You should always + * use this function to free JPEG destination buffer(s) that were automatically + * (re)allocated by #tjCompress2() or #tjTransform() or that were manually + * allocated using #tjAlloc(). + * + * @param buffer address of the buffer to free + */ +DLLEXPORT void DLLCALL tjFree(unsigned char *buffer); + + +/** * Returns a descriptive error message explaining why the last command failed. * * @return a descriptive error message explaining why the last command failed. |