blob: 05e24f69db59521cdcb2ec8dbd17317c74a884de [file] [log] [blame]
Thomas G. Lane4a6b7301992-03-17 00:00:00 +00001/*
2 * jmemnobs.c (jmemsys.c)
3 *
4 * Copyright (C) 1992, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
7 *
8 * This file provides a really simple implementation of the system-
9 * dependent portion of the JPEG memory manager. This implementation
10 * assumes that no backing-store files are needed: all required space
11 * can be obtained from malloc().
12 * This is very portable in the sense that it'll compile on almost anything,
13 * but you'd better have lots of main memory (or virtual memory) if you want
14 * to process big images.
15 * Note that the max_memory_to_use option is ignored by this implementation.
16 */
17
18#include "jinclude.h"
19#include "jmemsys.h"
20
21#ifdef INCLUDES_ARE_ANSI
22#include <stdlib.h> /* to declare malloc(), free() */
23#else
24extern void * malloc PP((size_t size));
25extern void free PP((void *ptr));
26#endif
27
28
29static external_methods_ptr methods; /* saved for access to error_exit */
30
31
32/*
33 * Memory allocation and freeing are controlled by the regular library
34 * routines malloc() and free().
35 */
36
37GLOBAL void *
38jget_small (size_t sizeofobject)
39{
40 return (void *) malloc(sizeofobject);
41}
42
43GLOBAL void
44jfree_small (void * object)
45{
46 free(object);
47}
48
49/*
50 * We assume NEED_FAR_POINTERS is not defined and so the separate entry points
51 * jget_large, jfree_large are not needed.
52 */
53
54
55/*
56 * This routine computes the total memory space available for allocation.
57 * Here we always say, "we got all you want bud!"
58 */
59
60GLOBAL long
61jmem_available (long min_bytes_needed, long max_bytes_needed)
62{
63 return max_bytes_needed;
64}
65
66
67/*
68 * Backing store (temporary file) management.
69 * This should never be called and we just error out.
70 */
71
72GLOBAL void
73jopen_backing_store (backing_store_ptr info, long total_bytes_needed)
74{
75 ERREXIT(methods, "Backing store not supported");
76}
77
78
79/*
80 * These routines take care of any system-dependent initialization and
81 * cleanup required. Keep in mind that jmem_term may be called more than
82 * once.
83 */
84
85GLOBAL void
86jmem_init (external_methods_ptr emethods)
87{
88 methods = emethods; /* save struct addr for error exit access */
89 emethods->max_memory_to_use = 0;
90}
91
92GLOBAL void
93jmem_term (void)
94{
95 /* no work */
96}