0N/A * reserved comment block 0N/A * DO NOT REMOVE OR ALTER! 0N/A * Copyright (C) 1992-1997, Thomas G. Lane. 0N/A * This file is part of the Independent JPEG Group's software. 0N/A * For conditions of distribution and use, see the accompanying README file. 0N/A * This include file defines the interface between the system-independent 0N/A * and system-dependent portions of the JPEG memory manager. No other 0N/A * modules need include it. (The system-independent portion is jmemmgr.c; 0N/A * there are several different versions of the system-dependent portion.) 0N/A * This file works as-is for the system-dependent memory managers supplied 0N/A * in the IJG distribution. You may need to modify it if you write a 0N/A * custom memory manager. If system-dependent changes are needed in 0N/A * this file, the best method is to #ifdef them based on a configuration 0N/A * symbol supplied in jconfig.h, as we have done with USE_MSDOS_MEMMGR 0N/A * and USE_MAC_MEMMGR. 0N/A/* Short forms of external names for systems with brain-damaged linkers. */ 0N/A#
endif /* NEED_SHORT_EXTERNAL_NAMES */ 0N/A * These two functions are used to allocate and release small chunks of 0N/A * memory. (Typically the total amount requested through jpeg_get_small is 0N/A * no more than 20K or so; this will be requested in chunks of a few K each.) 0N/A * Behavior should be the same as for the standard library functions malloc 0N/A * and free; in particular, jpeg_get_small must return NULL on failure. 0N/A * On most systems, these ARE malloc and free. jpeg_free_small is passed the 0N/A * size of the object being freed, just in case it's needed. 0N/A * On an 80x86 machine using small-data memory model, these manage near heap. 0N/A * These two functions are used to allocate and release large chunks of 0N/A * memory (up to the total free space designated by jpeg_mem_available). 0N/A * The interface is the same as above, except that on an 80x86 machine, 0N/A * far pointers are used. On most other machines these are identical to 0N/A * in case a different allocation strategy is desirable for large chunks. 0N/A * The macro MAX_ALLOC_CHUNK designates the maximum number of bytes that may 0N/A * be requested in a single call to jpeg_get_large (and jpeg_get_small for that 0N/A * matter, but that case should never come into play). This macro is needed 0N/A * to model the 64Kb-segment-size limit of far addressing on 80x86 machines. 0N/A * On those machines, we expect that jconfig.h will provide a proper value. 0N/A * On machines with 32-bit flat address spaces, any large constant may be used. 0N/A * NB: jmemmgr.c expects that MAX_ALLOC_CHUNK will be representable as type 0N/A * size_t and will be a multiple of sizeof(align_type). 0N/A * This routine computes the total space still available for allocation by 0N/A * jpeg_get_large. If more space than this is needed, backing store will be 0N/A * used. NOTE: any memory already allocated must not be counted. 0N/A * There is a minimum space requirement, corresponding to the minimum 0N/A * feasible buffer sizes; jmemmgr.c will request that much space even if 0N/A * jpeg_mem_available returns zero. The maximum space needed, enough to hold 0N/A * all working storage in memory, is also passed in case it is useful. 0N/A * Finally, the total space already allocated is passed. If no better 0N/A * method is available, cinfo->mem->max_memory_to_use - already_allocated 0N/A * is often a suitable calculation. 0N/A * It is OK for jpeg_mem_available to underestimate the space available 0N/A * (that'll just lead to more backing-store access than is really necessary). 0N/A * However, an overestimate will lead to failure. Hence it's wise to subtract 0N/A * a slop factor from the true available space. 5% should be enough. 0N/A * On machines with lots of virtual memory, any large constant may be returned. 0N/A * Conversely, zero may be returned to always use the minimum amount of memory. 0N/A * This structure holds whatever state is needed to access a single 0N/A * by jmemmgr.c to manipulate the backing-store object; all other fields 0N/A * are private to the system-dependent backing store routines. 0N/Atypedef unsigned short XMSH;
/* type of extended-memory handles */ 0N/Atypedef unsigned short EMSH;
/* type of expanded-memory handles */ 0N/A#
endif /* USE_MSDOS_MEMMGR */ 0N/A#
endif /* USE_MAC_MEMMGR */ 0N/A /* Private fields for system-dependent backing-store management */ 0N/A /* For a typical implementation with temp files, we need: */ 0N/A * Initial opening of a backing-store object. This must fill in the 0N/A * may take an error exit if the specified maximum file size is exceeded. 0N/A * (If jpeg_mem_available always returns a large value, this routine can 0N/A * just take an error exit.) 0N/A * These routines take care of any system-dependent initialization and 0N/A * cleanup required. jpeg_mem_init will be called before anything is 0N/A * allocated (and, therefore, nothing in cinfo is of use except the error 0N/A * manager pointer). It should return a suitable default value for 0N/A * max_memory_to_use; this may subsequently be overridden by the surrounding 0N/A * application. (Note that max_memory_to_use is only important if 0N/A * jpeg_mem_available chooses to consult it ... no one else will.) 0N/A * jpeg_mem_term may assume that all requested memory has been freed and that 0N/A * all opened backing-store objects have been closed.