4f10b2f0d7c85c8b77000c7ae30bd01c11bf5473
[oweals/cde.git] / cde / lib / DtHelp / jpeg / jmemnobs.c
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: jmemnobs.c /main/2 1996/05/09 03:52:28 drk $ */
24 /*
25  * jmemnobs.c
26  *
27  * Copyright (C) 1992-1996, Thomas G. Lane.
28  * This file is part of the Independent JPEG Group's software.
29  * For conditions of distribution and use, see the accompanying README file.
30  *
31  * This file provides a really simple implementation of the system-
32  * dependent portion of the JPEG memory manager.  This implementation
33  * assumes that no backing-store files are needed: all required space
34  * can be obtained from malloc().
35  * This is very portable in the sense that it'll compile on almost anything,
36  * but you'd better have lots of main memory (or virtual memory) if you want
37  * to process big images.
38  * Note that the max_memory_to_use option is ignored by this implementation.
39  */
40
41 #define JPEG_INTERNALS
42 #include "jinclude.h"
43 #include "jpeglib.h"
44 #include "jmemsys.h"            /* import the system-dependent declarations */
45
46 #ifndef HAVE_STDLIB_H           /* <stdlib.h> should declare malloc(),free() */
47 extern void * malloc JPP((size_t size));
48 extern void free JPP((void *ptr));
49 #endif
50
51
52 /*
53  * Memory allocation and freeing are controlled by the regular library
54  * routines malloc() and free().
55  */
56
57 GLOBAL(void *)
58 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
59 {
60   return (void *) malloc(sizeofobject);
61 }
62
63 GLOBAL(void)
64 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
65 {
66   free(object);
67 }
68
69
70 /*
71  * "Large" objects are treated the same as "small" ones.
72  * NB: although we include FAR keywords in the routine declarations,
73  * this file won't actually work in 80x86 small/medium model; at least,
74  * you probably won't be able to process useful-size images in only 64KB.
75  */
76
77 GLOBAL(void FAR *)
78 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
79 {
80   return (void FAR *) malloc(sizeofobject);
81 }
82
83 GLOBAL(void)
84 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
85 {
86   free(object);
87 }
88
89
90 /*
91  * This routine computes the total memory space available for allocation.
92  * Here we always say, "we got all you want bud!"
93  */
94
95 GLOBAL(long)
96 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
97                     long max_bytes_needed, long already_allocated)
98 {
99   return max_bytes_needed;
100 }
101
102
103 /*
104  * Backing store (temporary file) management.
105  * Since jpeg_mem_available always promised the moon,
106  * this should never be called and we can just error out.
107  */
108
109 GLOBAL(void)
110 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
111                          long total_bytes_needed)
112 {
113   ERREXIT(cinfo, JERR_NO_BACKING_STORE);
114 }
115
116
117 /*
118  * These routines take care of any system-dependent initialization and
119  * cleanup required.  Here, there isn't any.
120  */
121
122 GLOBAL(long)
123 jpeg_mem_init (j_common_ptr cinfo)
124 {
125   return 0;                     /* just set max_memory_to_use to 0 */
126 }
127
128 GLOBAL(void)
129 jpeg_mem_term (j_common_ptr cinfo)
130 {
131   /* no work */
132 }