home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 June / HDC50.iso / Info / Extras / Jpeg / SRC / JMEMPAS.C < prev    next >
C/C++ Source or Header  |  1999-08-11  |  2KB  |  101 lines

  1. /*
  2.  * jmempas.c
  3.  *
  4.  * This file maps the jpeg memory management calls into the Delphi memory
  5.  * manager.  This file is equivalent to jmemnobs.c, which assumes the
  6.  * operating system will take care of allocating and swapping virtual memory
  7.  * as needed for large memory requests.
  8.  */
  9.  
  10. #define JPEG_INTERNALS
  11. #include "jinclude.h"
  12. #include "jpeglib.h"
  13. #include "jmemsys.h"        /* import the system-dependent declarations */
  14.  
  15. extern void GetMem (void **ptr, size_t size);
  16. extern void FreeMem (void *ptr);
  17.  
  18. /*
  19.  * Memory allocation and freeing are controlled by the regular library
  20.  * routines malloc() and free().
  21.  */
  22.  
  23. GLOBAL(void *)
  24. jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
  25. {
  26.   void * temp;
  27.   GetMem(temp, sizeofobject);
  28.   return (temp);
  29. }
  30.  
  31. GLOBAL(void)
  32. jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
  33. {
  34.   FreeMem(object);
  35. }
  36.  
  37.  
  38. /*
  39.  * "Large" objects are treated the same as "small" ones.
  40.  * NB: although we include FAR keywords in the routine declarations,
  41.  * this file won't actually work in 80x86 small/medium model; at least,
  42.  * you probably won't be able to process useful-size images in only 64KB.
  43.  */
  44.  
  45. GLOBAL(void FAR *)
  46. jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
  47. {
  48.   return (void FAR *) jpeg_get_small(cinfo, sizeofobject);
  49. }
  50.  
  51. GLOBAL(void)
  52. jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
  53. {
  54.   jpeg_free_small(cinfo, object, sizeofobject);
  55. }
  56.  
  57.  
  58. /*
  59.  * This routine computes the total memory space available for allocation.
  60.  * Here we always say, "we got all you want bud!"
  61.  */
  62.  
  63. GLOBAL(long)
  64. jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
  65.             long max_bytes_needed, long already_allocated)
  66. {
  67.   return max_bytes_needed;
  68. }
  69.  
  70.  
  71. /*
  72.  * Backing store (temporary file) management.
  73.  * Since jpeg_mem_available always promised the moon,
  74.  * this should never be called and we can just error out.
  75.  */
  76.  
  77. GLOBAL(void)
  78. jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
  79.              long total_bytes_needed)
  80. {
  81.   ERREXIT(cinfo, JERR_NO_BACKING_STORE);
  82. }
  83.  
  84.  
  85. /*
  86.  * These routines take care of any system-dependent initialization and
  87.  * cleanup required.  Here, there isn't any.
  88.  */
  89.  
  90. GLOBAL(long)
  91. jpeg_mem_init (j_common_ptr cinfo)
  92. {
  93.   return 0;            /* just set max_memory_to_use to 0 */
  94. }
  95.  
  96. GLOBAL(void)
  97. jpeg_mem_term (j_common_ptr cinfo)
  98. {
  99.   /* no work */
  100. }
  101.