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