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