Path: blob/master/src/java.desktop/share/native/libjavajpeg/jmemnobs.c
41149 views
/*1* reserved comment block2* DO NOT REMOVE OR ALTER!3*/4/*5* jmemnobs.c6*7* Copyright (C) 1992-1996, Thomas G. Lane.8* This file is part of the Independent JPEG Group's software.9* For conditions of distribution and use, see the accompanying README file.10*11* This file provides a really simple implementation of the system-12* dependent portion of the JPEG memory manager. This implementation13* assumes that no backing-store files are needed: all required space14* can be obtained from malloc().15* This is very portable in the sense that it'll compile on almost anything,16* but you'd better have lots of main memory (or virtual memory) if you want17* to process big images.18* Note that the max_memory_to_use option is ignored by this implementation.19*/2021#define JPEG_INTERNALS22#include "jinclude.h"23#include "jpeglib.h"24#include "jmemsys.h" /* import the system-dependent declarations */2526#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */27extern void * malloc JPP((size_t size));28extern void free JPP((void *ptr));29#endif303132/*33* Memory allocation and freeing are controlled by the regular library34* routines malloc() and free().35*/3637GLOBAL(void *)38jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)39{40return (void *) malloc(sizeofobject);41}4243GLOBAL(void)44jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)45{46free(object);47}484950/*51* "Large" objects are treated the same as "small" ones.52* NB: although we include FAR keywords in the routine declarations,53* this file won't actually work in 80x86 small/medium model; at least,54* you probably won't be able to process useful-size images in only 64KB.55*/5657GLOBAL(void FAR *)58jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)59{60return (void FAR *) malloc(sizeofobject);61}6263GLOBAL(void)64jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)65{66free(object);67}686970/*71* This routine computes the total memory space available for allocation.72*/7374GLOBAL(size_t)75jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed,76size_t max_bytes_needed, size_t already_allocated)77{78if (cinfo->mem->max_memory_to_use)79return cinfo->mem->max_memory_to_use - already_allocated;8081/* Here we say, "we got all you want bud!" */82return max_bytes_needed;83}848586/*87* Backing store (temporary file) management.88* Since jpeg_mem_available always promised the moon,89* this should never be called and we can just error out.90*/9192GLOBAL(void)93jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,94long total_bytes_needed)95{96ERREXIT(cinfo, JERR_NO_BACKING_STORE);97}9899100/*101* These routines take care of any system-dependent initialization and102* cleanup required. Here, there isn't any.103*/104105GLOBAL(size_t)106jpeg_mem_init (j_common_ptr cinfo)107{108return 0; /* just set max_memory_to_use to 0 */109}110111GLOBAL(void)112jpeg_mem_term (j_common_ptr cinfo)113{114/* no work */115}116117118