Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

645 lines
20 KiB

  1. /*
  2. * jmemdos.c
  3. *
  4. * Copyright (C) 1992-1994, Thomas G. Lane.
  5. * This file is part of the Independent JPEG Group's software.
  6. * For conditions of distribution and use, see the accompanying README file.
  7. *
  8. * This file provides an MS-DOS-compatible implementation of the system-
  9. * dependent portion of the JPEG memory manager. Temporary data can be
  10. * stored in extended or expanded memory as well as in regular DOS files.
  11. *
  12. * If you use this file, you must be sure that NEED_FAR_POINTERS is defined
  13. * if you compile in a small-data memory model; it should NOT be defined if
  14. * you use a large-data memory model. This file is not recommended if you
  15. * are using a flat-memory-space 386 environment such as DJGCC or Watcom C.
  16. * Also, this code will NOT work if struct fields are aligned on greater than
  17. * 2-byte boundaries.
  18. *
  19. * Based on code contributed by Ge' Weijers.
  20. */
  21. /*
  22. * If you have both extended and expanded memory, you may want to change the
  23. * order in which they are tried in jopen_backing_store. On a 286 machine
  24. * expanded memory is usually faster, since extended memory access involves
  25. * an expensive protected-mode-and-back switch. On 386 and better, extended
  26. * memory is usually faster. As distributed, the code tries extended memory
  27. * first (what? not everyone has a 386? :-).
  28. *
  29. * You can disable use of extended/expanded memory entirely by altering these
  30. * definitions or overriding them from the Makefile (eg, -DEMS_SUPPORTED=0).
  31. */
  32. #ifndef XMS_SUPPORTED
  33. #define XMS_SUPPORTED 1
  34. #endif
  35. #ifndef EMS_SUPPORTED
  36. #define EMS_SUPPORTED 1
  37. #endif
  38. #define JPEG_INTERNALS
  39. #include "jinclude.h"
  40. #include "jpeglib.h"
  41. #include "jmemsys.h" /* import the system-dependent declarations */
  42. #ifndef HAVE_STDLIB_H /* <stdlib.h> should declare these */
  43. extern void * malloc JPP((size_t size));
  44. extern void free JPP((void *ptr));
  45. extern char * getenv JPP((const char * name));
  46. #endif
  47. #ifdef NEED_FAR_POINTERS
  48. #ifdef __TURBOC__
  49. /* These definitions work for Borland C (Turbo C) */
  50. #include <alloc.h> /* need farmalloc(), farfree() */
  51. #define far_malloc(x) farmalloc(x)
  52. #define far_free(x) farfree(x)
  53. #else
  54. /* These definitions work for Microsoft C and compatible compilers */
  55. #include <malloc.h> /* need _fmalloc(), _ffree() */
  56. #define far_malloc(x) _fmalloc(x)
  57. #define far_free(x) _ffree(x)
  58. #endif
  59. #else /* not NEED_FAR_POINTERS */
  60. #define far_malloc(x) malloc(x)
  61. #define far_free(x) free(x)
  62. #endif /* NEED_FAR_POINTERS */
  63. #ifdef DONT_USE_B_MODE /* define mode parameters for fopen() */
  64. #define READ_BINARY "r"
  65. #else
  66. #define READ_BINARY "rb"
  67. #endif
  68. #if MAX_ALLOC_CHUNK >= 65535L /* make sure jconfig.h got this right */
  69. MAX_ALLOC_CHUNK should be less than 64K. /* deliberate syntax error */
  70. #endif
  71. /*
  72. * Declarations for assembly-language support routines (see jmemdosa.asm).
  73. *
  74. * The functions are declared "far" as are all pointer arguments;
  75. * this ensures the assembly source code will work regardless of the
  76. * compiler memory model. We assume "short" is 16 bits, "long" is 32.
  77. */
  78. typedef void far * XMSDRIVER; /* actually a pointer to code */
  79. typedef struct { /* registers for calling XMS driver */
  80. unsigned short ax, dx, bx;
  81. void far * ds_si;
  82. } XMScontext;
  83. typedef struct { /* registers for calling EMS driver */
  84. unsigned short ax, dx, bx;
  85. void far * ds_si;
  86. } EMScontext;
  87. EXTERN short far jdos_open JPP((short far * handle, char far * filename));
  88. EXTERN short far jdos_close JPP((short handle));
  89. EXTERN short far jdos_seek JPP((short handle, long offset));
  90. EXTERN short far jdos_read JPP((short handle, void far * buffer,
  91. unsigned short count));
  92. EXTERN short far jdos_write JPP((short handle, void far * buffer,
  93. unsigned short count));
  94. EXTERN void far jxms_getdriver JPP((XMSDRIVER far *));
  95. EXTERN void far jxms_calldriver JPP((XMSDRIVER, XMScontext far *));
  96. EXTERN short far jems_available JPP((void));
  97. EXTERN void far jems_calldriver JPP((EMScontext far *));
  98. /*
  99. * Selection of a file name for a temporary file.
  100. * This is highly system-dependent, and you may want to customize it.
  101. */
  102. static int next_file_num; /* to distinguish among several temp files */
  103. LOCAL void
  104. select_file_name (char * fname)
  105. {
  106. const char * env;
  107. char * ptr;
  108. FILE * tfile;
  109. /* Keep generating file names till we find one that's not in use */
  110. for (;;) {
  111. /* Get temp directory name from environment TMP or TEMP variable;
  112. * if none, use "."
  113. */
  114. if ((env = (const char *) getenv("TMP")) == NULL)
  115. if ((env = (const char *) getenv("TEMP")) == NULL)
  116. env = ".";
  117. if (*env == '\0') /* null string means "." */
  118. env = ".";
  119. ptr = fname; /* copy name to fname */
  120. while (*env != '\0')
  121. *ptr++ = *env++;
  122. if (ptr[-1] != '\\' && ptr[-1] != '/')
  123. *ptr++ = '\\'; /* append backslash if not in env variable */
  124. /* Append a suitable file name */
  125. next_file_num++; /* advance counter */
  126. wsprintf(ptr, "JPG%03d.TMP", next_file_num);
  127. /* Probe to see if file name is already in use */
  128. #ifdef DEAD_CODE
  129. if ((tfile = fopen(fname, READ_BINARY)) == NULL)
  130. break;
  131. fclose(tfile); /* oops, it's there; close tfile & try again */
  132. #endif
  133. }
  134. }
  135. /*
  136. * Near-memory allocation and freeing are controlled by the regular library
  137. * routines malloc() and free().
  138. */
  139. // Removed to eliminate Compiler Warnings. TML 6/8/98
  140. /*
  141. GLOBAL void *
  142. jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
  143. {
  144. return (void *) malloc(sizeofobject);
  145. }
  146. GLOBAL void
  147. jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
  148. {
  149. free(object);
  150. }
  151. //
  152. // "Large" objects are allocated in far memory, if possible
  153. //
  154. GLOBAL void FAR *
  155. jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
  156. {
  157. return (void FAR *) far_malloc(sizeofobject);
  158. }
  159. GLOBAL void
  160. jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
  161. {
  162. far_free(object);
  163. }
  164. */
  165. //
  166. // This routine computes the total memory space available for allocation.
  167. // It's impossible to do this in a portable way; our current solution is
  168. // to make the user tell us (with a default value set at compile time).
  169. // if you can actually get the available space, it's a good idea to subtract
  170. // slop factor of 5% or so.
  171. //
  172. #ifndef DEFAULT_MAX_MEM // so can override from makefile
  173. #define DEFAULT_MAX_MEM 300000L // for total usage about 450K
  174. #endif
  175. // Removed to eliminate Compiler Warnings. TML 6/8/98
  176. /*
  177. GLOBAL long
  178. jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
  179. long max_bytes_needed, long already_allocated)
  180. {
  181. return cinfo->mem->max_memory_to_use - already_allocated;
  182. }
  183. */
  184. //
  185. // Backing store (temporary file) management.
  186. // Backing store objects are only used when the value returned by
  187. // jpeg_mem_available is less than the total space needed. You can dispense
  188. // with these routines if you have plenty of virtual memory; see jmemnobs.c.
  189. //
  190. //
  191. // For MS-DOS we support three types of backing storage:
  192. // 1. Conventional DOS files. We access these by direct DOS calls rather
  193. // than via the stdio package. This provides a bit better performance,
  194. // but the real reason is that the buffers to be read or written are FAR.
  195. // The stdio library for small-data memory models can't cope with that.
  196. // 2. Extended memory, accessed per the XMS V2.0 specification.
  197. // 3. Expanded memory, accessed per the LIM/EMS 4.0 specification.
  198. // You'll need copies of those specs to make sense of the related code.
  199. // The specs are available by Internet FTP from the SIMTEL archives
  200. // (oak.oakland.edu and its various mirror sites). See files
  201. // pub/msdos/microsoft/xms20.arc and pub/msdos/info/limems41.zip.
  202. //
  203. //
  204. // Access methods for a DOS file.
  205. //
  206. METHODDEF void
  207. read_file_store (j_common_ptr cinfo, backing_store_ptr info,
  208. void FAR * buffer_address,
  209. long file_offset, long byte_count)
  210. {
  211. if (jdos_seek(info->handle.file_handle, file_offset))
  212. ERREXIT(cinfo, JERR_TFILE_SEEK);
  213. /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
  214. if (byte_count > 65535L) /* safety check */
  215. ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
  216. if (jdos_read(info->handle.file_handle, buffer_address,
  217. (unsigned short) byte_count))
  218. ERREXIT(cinfo, JERR_TFILE_READ);
  219. }
  220. METHODDEF void
  221. write_file_store (j_common_ptr cinfo, backing_store_ptr info,
  222. void FAR * buffer_address,
  223. long file_offset, long byte_count)
  224. {
  225. if (jdos_seek(info->handle.file_handle, file_offset))
  226. ERREXIT(cinfo, JERR_TFILE_SEEK);
  227. /* Since MAX_ALLOC_CHUNK is less than 64K, byte_count will be too. */
  228. if (byte_count > 65535L) /* safety check */
  229. ERREXIT(cinfo, JERR_BAD_ALLOC_CHUNK);
  230. if (jdos_write(info->handle.file_handle, buffer_address,
  231. (unsigned short) byte_count))
  232. ERREXIT(cinfo, JERR_TFILE_WRITE);
  233. }
  234. METHODDEF void
  235. close_file_store (j_common_ptr cinfo, backing_store_ptr info)
  236. {
  237. jdos_close(info->handle.file_handle); /* close the file */
  238. remove(info->temp_name); /* delete the file */
  239. /* If your system doesn't have remove(), try unlink() instead.
  240. * remove() is the ANSI-standard name for this function, but
  241. * unlink() was more common in pre-ANSI systems.
  242. */
  243. TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);
  244. }
  245. // Removed to eliminate Compiler Warnings. TML 6/8/98
  246. /*
  247. LOCAL boolean
  248. open_file_store (j_common_ptr cinfo, backing_store_ptr info,
  249. long total_bytes_needed)
  250. {
  251. short handle;
  252. select_file_name(info->temp_name);
  253. if (jdos_open((short far *) & handle, (char far *) info->temp_name)) {
  254. // might as well exit since jpeg_open_backing_store will fail anyway
  255. ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
  256. return FALSE;
  257. }
  258. info->handle.file_handle = handle;
  259. info->read_backing_store = read_file_store;
  260. info->write_backing_store = write_file_store;
  261. info->close_backing_store = close_file_store;
  262. TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
  263. return TRUE; // succeeded
  264. }
  265. */
  266. //
  267. // Access methods for extended memory.
  268. //
  269. #if XMS_SUPPORTED
  270. static XMSDRIVER xms_driver; /* saved address of XMS driver */
  271. typedef union { /* either long offset or real-mode pointer */
  272. long offset;
  273. void far * ptr;
  274. } XMSPTR;
  275. typedef struct { /* XMS move specification structure */
  276. long length;
  277. XMSH src_handle;
  278. XMSPTR src;
  279. XMSH dst_handle;
  280. XMSPTR dst;
  281. } XMSspec;
  282. #define ODD(X) (((X) & 1L) != 0)
  283. METHODDEF void
  284. read_xms_store (j_common_ptr cinfo, backing_store_ptr info,
  285. void FAR * buffer_address,
  286. long file_offset, long byte_count)
  287. {
  288. XMScontext ctx;
  289. XMSspec spec;
  290. char endbuffer[2];
  291. /* The XMS driver can't cope with an odd length, so handle the last byte
  292. * specially if byte_count is odd. We don't expect this to be common.
  293. */
  294. spec.length = byte_count & (~ 1L);
  295. spec.src_handle = info->handle.xms_handle;
  296. spec.src.offset = file_offset;
  297. spec.dst_handle = 0;
  298. spec.dst.ptr = buffer_address;
  299. ctx.ds_si = (void far *) & spec;
  300. ctx.ax = 0x0b00; /* EMB move */
  301. jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
  302. if (ctx.ax != 1)
  303. ERREXIT(cinfo, JERR_XMS_READ);
  304. if (ODD(byte_count)) {
  305. read_xms_store(cinfo, info, (void FAR *) endbuffer,
  306. file_offset + byte_count - 1L, 2L);
  307. ((char FAR *) buffer_address)[byte_count - 1L] = endbuffer[0];
  308. }
  309. }
  310. METHODDEF void
  311. write_xms_store (j_common_ptr cinfo, backing_store_ptr info,
  312. void FAR * buffer_address,
  313. long file_offset, long byte_count)
  314. {
  315. XMScontext ctx;
  316. XMSspec spec;
  317. char endbuffer[2];
  318. /* The XMS driver can't cope with an odd length, so handle the last byte
  319. * specially if byte_count is odd. We don't expect this to be common.
  320. */
  321. spec.length = byte_count & (~ 1L);
  322. spec.src_handle = 0;
  323. spec.src.ptr = buffer_address;
  324. spec.dst_handle = info->handle.xms_handle;
  325. spec.dst.offset = file_offset;
  326. ctx.ds_si = (void far *) & spec;
  327. ctx.ax = 0x0b00; /* EMB move */
  328. jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
  329. if (ctx.ax != 1)
  330. ERREXIT(cinfo, JERR_XMS_WRITE);
  331. if (ODD(byte_count)) {
  332. read_xms_store(cinfo, info, (void FAR *) endbuffer,
  333. file_offset + byte_count - 1L, 2L);
  334. endbuffer[0] = ((char FAR *) buffer_address)[byte_count - 1L];
  335. write_xms_store(cinfo, info, (void FAR *) endbuffer,
  336. file_offset + byte_count - 1L, 2L);
  337. }
  338. }
  339. METHODDEF void
  340. close_xms_store (j_common_ptr cinfo, backing_store_ptr info)
  341. {
  342. XMScontext ctx;
  343. ctx.dx = info->handle.xms_handle;
  344. ctx.ax = 0x0a00;
  345. jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
  346. TRACEMS1(cinfo, 1, JTRC_XMS_CLOSE, info->handle.xms_handle);
  347. /* we ignore any error return from the driver */
  348. }
  349. LOCAL boolean
  350. open_xms_store (j_common_ptr cinfo, backing_store_ptr info,
  351. long total_bytes_needed)
  352. {
  353. XMScontext ctx;
  354. /* Get address of XMS driver */
  355. jxms_getdriver((XMSDRIVER far *) & xms_driver);
  356. if (xms_driver == NULL)
  357. return FALSE; /* no driver to be had */
  358. /* Get version number, must be >= 2.00 */
  359. ctx.ax = 0x0000;
  360. jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
  361. if (ctx.ax < (unsigned short) 0x0200)
  362. return FALSE;
  363. /* Try to get space (expressed in kilobytes) */
  364. ctx.dx = (unsigned short) ((total_bytes_needed + 1023L) >> 10);
  365. ctx.ax = 0x0900;
  366. jxms_calldriver(xms_driver, (XMScontext far *) & ctx);
  367. if (ctx.ax != 1)
  368. return FALSE;
  369. /* Succeeded, save the handle and away we go */
  370. info->handle.xms_handle = ctx.dx;
  371. info->read_backing_store = read_xms_store;
  372. info->write_backing_store = write_xms_store;
  373. info->close_backing_store = close_xms_store;
  374. TRACEMS1(cinfo, 1, JTRC_XMS_OPEN, ctx.dx);
  375. return TRUE; // succeeded
  376. }
  377. #endif /* XMS_SUPPORTED */
  378. /*
  379. * Access methods for expanded memory.
  380. */
  381. #if EMS_SUPPORTED
  382. /* The EMS move specification structure requires word and long fields aligned
  383. * at odd byte boundaries. Some compilers will align struct fields at even
  384. * byte boundaries. While it's usually possible to force byte alignment,
  385. * that causes an overall performance penalty and may pose problems in merging
  386. * JPEG into a larger application. Instead we accept some rather dirty code
  387. * here. Note this code would fail if the hardware did not allow odd-byte
  388. * word & long accesses, but all 80x86 CPUs do.
  389. */
  390. typedef void far * EMSPTR;
  391. typedef union { /* EMS move specification structure */
  392. long length; /* It's easy to access first 4 bytes */
  393. char bytes[18]; /* Misaligned fields in here! */
  394. } EMSspec;
  395. /* Macros for accessing misaligned fields */
  396. #define FIELD_AT(spec,offset,type) (*((type *) &(spec.bytes[offset])))
  397. #define SRC_TYPE(spec) FIELD_AT(spec,4,char)
  398. #define SRC_HANDLE(spec) FIELD_AT(spec,5,EMSH)
  399. #define SRC_OFFSET(spec) FIELD_AT(spec,7,unsigned short)
  400. #define SRC_PAGE(spec) FIELD_AT(spec,9,unsigned short)
  401. #define SRC_PTR(spec) FIELD_AT(spec,7,EMSPTR)
  402. #define DST_TYPE(spec) FIELD_AT(spec,11,char)
  403. #define DST_HANDLE(spec) FIELD_AT(spec,12,EMSH)
  404. #define DST_OFFSET(spec) FIELD_AT(spec,14,unsigned short)
  405. #define DST_PAGE(spec) FIELD_AT(spec,16,unsigned short)
  406. #define DST_PTR(spec) FIELD_AT(spec,14,EMSPTR)
  407. #define EMSPAGESIZE 16384L /* gospel, see the EMS specs */
  408. #define HIBYTE(W) (((W) >> 8) & 0xFF)
  409. #define LOBYTE(W) ((W) & 0xFF)
  410. METHODDEF void
  411. read_ems_store (j_common_ptr cinfo, backing_store_ptr info,
  412. void FAR * buffer_address,
  413. long file_offset, long byte_count)
  414. {
  415. EMScontext ctx;
  416. EMSspec spec;
  417. spec.length = byte_count;
  418. SRC_TYPE(spec) = 1;
  419. SRC_HANDLE(spec) = info->handle.ems_handle;
  420. SRC_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE);
  421. SRC_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
  422. DST_TYPE(spec) = 0;
  423. DST_HANDLE(spec) = 0;
  424. DST_PTR(spec) = buffer_address;
  425. ctx.ds_si = (void far *) & spec;
  426. ctx.ax = 0x5700; /* move memory region */
  427. jems_calldriver((EMScontext far *) & ctx);
  428. if (HIBYTE(ctx.ax) != 0)
  429. ERREXIT(cinfo, JERR_EMS_READ);
  430. }
  431. METHODDEF void
  432. write_ems_store (j_common_ptr cinfo, backing_store_ptr info,
  433. void FAR * buffer_address,
  434. long file_offset, long byte_count)
  435. {
  436. EMScontext ctx;
  437. EMSspec spec;
  438. spec.length = byte_count;
  439. SRC_TYPE(spec) = 0;
  440. SRC_HANDLE(spec) = 0;
  441. SRC_PTR(spec) = buffer_address;
  442. DST_TYPE(spec) = 1;
  443. DST_HANDLE(spec) = info->handle.ems_handle;
  444. DST_PAGE(spec) = (unsigned short) (file_offset / EMSPAGESIZE);
  445. DST_OFFSET(spec) = (unsigned short) (file_offset % EMSPAGESIZE);
  446. ctx.ds_si = (void far *) & spec;
  447. ctx.ax = 0x5700; /* move memory region */
  448. jems_calldriver((EMScontext far *) & ctx);
  449. if (HIBYTE(ctx.ax) != 0)
  450. ERREXIT(cinfo, JERR_EMS_WRITE);
  451. }
  452. METHODDEF void
  453. close_ems_store (j_common_ptr cinfo, backing_store_ptr info)
  454. {
  455. EMScontext ctx;
  456. ctx.ax = 0x4500;
  457. ctx.dx = info->handle.ems_handle;
  458. jems_calldriver((EMScontext far *) & ctx);
  459. TRACEMS1(cinfo, 1, JTRC_EMS_CLOSE, info->handle.ems_handle);
  460. /* we ignore any error return from the driver */
  461. }
  462. LOCAL boolean
  463. open_ems_store (j_common_ptr cinfo, backing_store_ptr info,
  464. long total_bytes_needed)
  465. {
  466. EMScontext ctx;
  467. /* Is EMS driver there? */
  468. if (! jems_available())
  469. return FALSE;
  470. /* Get status, make sure EMS is OK */
  471. ctx.ax = 0x4000;
  472. jems_calldriver((EMScontext far *) & ctx);
  473. if (HIBYTE(ctx.ax) != 0)
  474. return FALSE;
  475. /* Get version, must be >= 4.0 */
  476. ctx.ax = 0x4600;
  477. jems_calldriver((EMScontext far *) & ctx);
  478. if (HIBYTE(ctx.ax) != 0 || LOBYTE(ctx.ax) < 0x40)
  479. return FALSE;
  480. /* Try to allocate requested space */
  481. ctx.ax = 0x4300;
  482. ctx.bx = (unsigned short) ((total_bytes_needed + EMSPAGESIZE-1L) / EMSPAGESIZE);
  483. jems_calldriver((EMScontext far *) & ctx);
  484. if (HIBYTE(ctx.ax) != 0)
  485. return FALSE;
  486. /* Succeeded, save the handle and away we go */
  487. info->handle.ems_handle = ctx.dx;
  488. info->read_backing_store = read_ems_store;
  489. info->write_backing_store = write_ems_store;
  490. info->close_backing_store = close_ems_store;
  491. TRACEMS1(cinfo, 1, JTRC_EMS_OPEN, ctx.dx);
  492. return TRUE; /* succeeded */
  493. }
  494. #endif /* EMS_SUPPORTED */
  495. //
  496. // Initial opening of a backing-store object.
  497. //
  498. GLOBAL void
  499. jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
  500. long total_bytes_needed)
  501. {
  502. // Try extended memory, then expanded memory, then regular file.
  503. #if XMS_SUPPORTED
  504. if (open_xms_store(cinfo, info, total_bytes_needed))
  505. return;
  506. #endif
  507. #if EMS_SUPPORTED
  508. if (open_ems_store(cinfo, info, total_bytes_needed))
  509. return;
  510. #endif
  511. if (open_file_store(cinfo, info, total_bytes_needed))
  512. return;
  513. ERREXITS(cinfo, JERR_TFILE_CREATE, "");
  514. }
  515. /*
  516. * These routines take care of any system-dependent initialization and
  517. * cleanup required.
  518. */
  519. // Removed to eliminate Compiler Warnings. TML 6/8/98
  520. /*
  521. GLOBAL long
  522. jpeg_mem_init (j_common_ptr cinfo)
  523. {
  524. next_file_num = 0; // initialize temp file name generator
  525. return DEFAULT_MAX_MEM; // default for max_memory_to_use
  526. }
  527. GLOBAL void
  528. jpeg_mem_term (j_common_ptr cinfo)
  529. {
  530. // Microsoft C, at least in v6.00A, will not successfully reclaim freed
  531. // blocks of size > 32Kbytes unless we give it a kick in the rear, like so:
  532. //
  533. #ifdef NEED_FHEAPMIN
  534. _fheapmin();
  535. #endif
  536. }
  537. */