michael@0: /* michael@0: * jmemnobs.c michael@0: * michael@0: * Copyright (C) 1992-1996, Thomas G. Lane. michael@0: * This file is part of the Independent JPEG Group's software. michael@0: * For conditions of distribution and use, see the accompanying README file. michael@0: * michael@0: * This file provides a really simple implementation of the system- michael@0: * dependent portion of the JPEG memory manager. This implementation michael@0: * assumes that no backing-store files are needed: all required space michael@0: * can be obtained from malloc(). michael@0: * This is very portable in the sense that it'll compile on almost anything, michael@0: * but you'd better have lots of main memory (or virtual memory) if you want michael@0: * to process big images. michael@0: * Note that the max_memory_to_use option is ignored by this implementation. michael@0: */ michael@0: michael@0: #define JPEG_INTERNALS michael@0: #include "jinclude.h" michael@0: #include "jpeglib.h" michael@0: #include "jmemsys.h" /* import the system-dependent declarations */ michael@0: michael@0: #ifndef HAVE_STDLIB_H /* should declare malloc(),free() */ michael@0: extern void * malloc JPP((size_t size)); michael@0: extern void free JPP((void *ptr)); michael@0: #endif michael@0: michael@0: michael@0: /* michael@0: * Memory allocation and freeing are controlled by the regular library michael@0: * routines malloc() and free(). michael@0: */ michael@0: michael@0: GLOBAL(void *) michael@0: jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) michael@0: { michael@0: return (void *) malloc(sizeofobject); michael@0: } michael@0: michael@0: GLOBAL(void) michael@0: jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) michael@0: { michael@0: free(object); michael@0: } michael@0: michael@0: michael@0: /* michael@0: * "Large" objects are treated the same as "small" ones. michael@0: * NB: although we include FAR keywords in the routine declarations, michael@0: * this file won't actually work in 80x86 small/medium model; at least, michael@0: * you probably won't be able to process useful-size images in only 64KB. michael@0: */ michael@0: michael@0: GLOBAL(void FAR *) michael@0: jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) michael@0: { michael@0: return (void FAR *) malloc(sizeofobject); michael@0: } michael@0: michael@0: GLOBAL(void) michael@0: jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) michael@0: { michael@0: free(object); michael@0: } michael@0: michael@0: michael@0: /* michael@0: * This routine computes the total memory space available for allocation. michael@0: * Here we always say, "we got all you want bud!" michael@0: */ michael@0: michael@0: GLOBAL(size_t) michael@0: jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed, michael@0: size_t max_bytes_needed, size_t already_allocated) michael@0: { michael@0: return max_bytes_needed; michael@0: } michael@0: michael@0: michael@0: /* michael@0: * Backing store (temporary file) management. michael@0: * Since jpeg_mem_available always promised the moon, michael@0: * this should never be called and we can just error out. michael@0: */ michael@0: michael@0: GLOBAL(void) michael@0: jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, michael@0: long total_bytes_needed) michael@0: { michael@0: ERREXIT(cinfo, JERR_NO_BACKING_STORE); michael@0: } michael@0: michael@0: michael@0: /* michael@0: * These routines take care of any system-dependent initialization and michael@0: * cleanup required. Here, there isn't any. michael@0: */ michael@0: michael@0: GLOBAL(long) michael@0: jpeg_mem_init (j_common_ptr cinfo) michael@0: { michael@0: return 0; /* just set max_memory_to_use to 0 */ michael@0: } michael@0: michael@0: GLOBAL(void) michael@0: jpeg_mem_term (j_common_ptr cinfo) michael@0: { michael@0: /* no work */ michael@0: }