Home | History | Annotate | Download | only in libjpeg
      1 #if !defined(_FX_JPEG_TURBO_)
      2 /*
      3  * jmemnobs.c
      4  *
      5  * Copyright (C) 1992-1996, Thomas G. Lane.
      6  * This file is part of the Independent JPEG Group's software.
      7  * For conditions of distribution and use, see the accompanying README file.
      8  *
      9  * This file provides a really simple implementation of the system-
     10  * dependent portion of the JPEG memory manager.  This implementation
     11  * assumes that no backing-store files are needed: all required space
     12  * can be obtained from malloc().
     13  * This is very portable in the sense that it'll compile on almost anything,
     14  * but you'd better have lots of main memory (or virtual memory) if you want
     15  * to process big images.
     16  * Note that the max_memory_to_use option is ignored by this implementation.
     17  */
     18 
     19 #define JPEG_INTERNALS
     20 #include "jinclude.h"
     21 #include "jpeglib.h"
     22 #include "jmemsys.h"		/* import the system-dependent declarations */
     23 
     24 #ifndef HAVE_STDLIB_H		/* <stdlib.h> should declare malloc(),free() */
     25 extern void * malloc JPP((size_t size));
     26 extern void free JPP((void *ptr));
     27 #endif
     28 
     29 #if defined(_FX_MANAGED_CODE_) && defined(__cplusplus)
     30 extern "C" {
     31 #endif
     32 
     33 void*	FXMEM_DefaultAlloc(int byte_size, int);
     34 void	FXMEM_DefaultFree(void* pointer, int);
     35 
     36 #if defined(_FX_MANAGED_CODE_) && defined(__cplusplus)
     37 }
     38 #endif
     39 
     40 /*
     41  * Memory allocation and freeing are controlled by the regular library
     42  * routines malloc() and free().
     43  */
     44 
     45 GLOBAL(void *)
     46 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
     47 {
     48 //  return (void *) malloc(sizeofobject);
     49 	return FXMEM_DefaultAlloc(sizeofobject, 0);
     50 }
     51 
     52 GLOBAL(void)
     53 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
     54 {
     55 //  free(object);
     56 	FXMEM_DefaultFree(object, 0);
     57 }
     58 
     59 
     60 /*
     61  * "Large" objects are treated the same as "small" ones.
     62  * NB: although we include FAR keywords in the routine declarations,
     63  * this file won't actually work in 80x86 small/medium model; at least,
     64  * you probably won't be able to process useful-size images in only 64KB.
     65  */
     66 
     67 GLOBAL(void FAR *)
     68 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
     69 {
     70 //  return (void FAR *) malloc(sizeofobject);
     71 	return FXMEM_DefaultAlloc(sizeofobject, 0);
     72 }
     73 
     74 GLOBAL(void)
     75 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
     76 {
     77 //  free(object);
     78 	FXMEM_DefaultFree(object, 0);
     79 }
     80 
     81 
     82 /*
     83  * This routine computes the total memory space available for allocation.
     84  * Here we always say, "we got all you want bud!"
     85  */
     86 
     87 GLOBAL(long)
     88 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
     89 		    long max_bytes_needed, long already_allocated)
     90 {
     91   return max_bytes_needed;
     92 }
     93 
     94 
     95 /*
     96  * Backing store (temporary file) management.
     97  * Since jpeg_mem_available always promised the moon,
     98  * this should never be called and we can just error out.
     99  */
    100 
    101 GLOBAL(void)
    102 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
    103 			 long total_bytes_needed)
    104 {
    105   ERREXIT(cinfo, JERR_NO_BACKING_STORE);
    106 }
    107 
    108 
    109 /*
    110  * These routines take care of any system-dependent initialization and
    111  * cleanup required.  Here, there isn't any.
    112  */
    113 
    114 GLOBAL(long)
    115 jpeg_mem_init (j_common_ptr cinfo)
    116 {
    117   return 0;			/* just set max_memory_to_use to 0 */
    118 }
    119 
    120 GLOBAL(void)
    121 jpeg_mem_term (j_common_ptr cinfo)
    122 {
    123   /* no work */
    124 }
    125 
    126 #endif //_FX_JPEG_TURBO_
    127