Back to index

plt-scheme  4.2.1
jmemnobs.c
Go to the documentation of this file.
00001 /*
00002  * jmemnobs.c
00003  *
00004  * Copyright (C) 1992-1996, Thomas G. Lane.
00005  * This file is part of the Independent JPEG Group's software.
00006  * For conditions of distribution and use, see the accompanying README file.
00007  *
00008  * This file provides a really simple implementation of the system-
00009  * dependent portion of the JPEG memory manager.  This implementation
00010  * assumes that no backing-store files are needed: all required space
00011  * can be obtained from malloc().
00012  * This is very portable in the sense that it'll compile on almost anything,
00013  * but you'd better have lots of main memory (or virtual memory) if you want
00014  * to process big images.
00015  * Note that the max_memory_to_use option is ignored by this implementation.
00016  */
00017 
00018 #define JPEG_INTERNALS
00019 #include "jinclude.h"
00020 #include "jpeglib.h"
00021 #include "jmemsys.h"        /* import the system-dependent declarations */
00022 
00023 #ifndef HAVE_STDLIB_H              /* <stdlib.h> should declare malloc(),free() */
00024 extern void * malloc JPP((size_t size));
00025 extern void free JPP((void *ptr));
00026 #endif
00027 
00028 
00029 /*
00030  * Memory allocation and freeing are controlled by the regular library
00031  * routines malloc() and free().
00032  */
00033 
00034 GLOBAL(void *)
00035 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
00036 {
00037   return (void *) malloc(sizeofobject);
00038 }
00039 
00040 GLOBAL(void)
00041 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
00042 {
00043   free(object);
00044 }
00045 
00046 
00047 /*
00048  * "Large" objects are treated the same as "small" ones.
00049  * NB: although we include FAR keywords in the routine declarations,
00050  * this file won't actually work in 80x86 small/medium model; at least,
00051  * you probably won't be able to process useful-size images in only 64KB.
00052  */
00053 
00054 GLOBAL(void FAR *)
00055 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
00056 {
00057   return (void FAR *) malloc(sizeofobject);
00058 }
00059 
00060 GLOBAL(void)
00061 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
00062 {
00063   free(object);
00064 }
00065 
00066 
00067 /*
00068  * This routine computes the total memory space available for allocation.
00069  * Here we always say, "we got all you want bud!"
00070  */
00071 
00072 GLOBAL(long)
00073 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
00074                   long max_bytes_needed, long already_allocated)
00075 {
00076   return max_bytes_needed;
00077 }
00078 
00079 
00080 /*
00081  * Backing store (temporary file) management.
00082  * Since jpeg_mem_available always promised the moon,
00083  * this should never be called and we can just error out.
00084  */
00085 
00086 GLOBAL(void)
00087 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
00088                       long total_bytes_needed)
00089 {
00090   ERREXIT(cinfo, JERR_NO_BACKING_STORE);
00091 }
00092 
00093 
00094 /*
00095  * These routines take care of any system-dependent initialization and
00096  * cleanup required.  Here, there isn't any.
00097  */
00098 
00099 GLOBAL(long)
00100 jpeg_mem_init (j_common_ptr cinfo)
00101 {
00102   return 0;                 /* just set max_memory_to_use to 0 */
00103 }
00104 
00105 GLOBAL(void)
00106 jpeg_mem_term (j_common_ptr cinfo)
00107 {
00108   /* no work */
00109 }