aboutsummaryrefslogtreecommitdiff
path: root/turbojpeg.h
diff options
context:
space:
mode:
authorDRC <dcommander@users.sourceforge.net>2011-05-24 16:52:47 +0000
committerDRC <dcommander@users.sourceforge.net>2011-05-24 16:52:47 +0000
commit6b76f75d2c0ebdc462f6bc663289fa4bfde1629a (patch)
tree25e4687068699d56c44b5016cd9288c700eb26a3 /turbojpeg.h
parent90215cca0ccd4fc69ecbde9a1d779cdaf5fe7c8d (diff)
downloadlibjpeg-turbo-6b76f75d2c0ebdc462f6bc663289fa4bfde1629a.tar.gz
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+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@634 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'turbojpeg.h')
-rw-r--r--turbojpeg.h33
1 files changed, 29 insertions, 4 deletions
diff --git a/turbojpeg.h b/turbojpeg.h
index 17bc306e..f6855479 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.