aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c334
1 files changed, 167 insertions, 167 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c
index b5da474..2d93e49 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c
+++ b/libraries/irrlicht-1.8/source/Irrlicht/jpeglib/jmemansi.c
@@ -1,167 +1,167 @@
1/* 1/*
2 * jmemansi.c 2 * jmemansi.c
3 * 3 *
4 * Copyright (C) 1992-1996, Thomas G. Lane. 4 * Copyright (C) 1992-1996, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software. 5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file. 6 * For conditions of distribution and use, see the accompanying README file.
7 * 7 *
8 * This file provides a simple generic implementation of the system- 8 * This file provides a simple generic implementation of the system-
9 * dependent portion of the JPEG memory manager. This implementation 9 * dependent portion of the JPEG memory manager. This implementation
10 * assumes that you have the ANSI-standard library routine tmpfile(). 10 * assumes that you have the ANSI-standard library routine tmpfile().
11 * Also, the problem of determining the amount of memory available 11 * Also, the problem of determining the amount of memory available
12 * is shoved onto the user. 12 * is shoved onto the user.
13 */ 13 */
14 14
15#define JPEG_INTERNALS 15#define JPEG_INTERNALS
16#include "jinclude.h" 16#include "jinclude.h"
17#include "jpeglib.h" 17#include "jpeglib.h"
18#include "jmemsys.h" /* import the system-dependent declarations */ 18#include "jmemsys.h" /* import the system-dependent declarations */
19 19
20#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */ 20#ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
21extern void * malloc JPP((size_t size)); 21extern void * malloc JPP((size_t size));
22extern void free JPP((void *ptr)); 22extern void free JPP((void *ptr));
23#endif 23#endif
24 24
25#ifndef SEEK_SET /* pre-ANSI systems may not define this; */ 25#ifndef SEEK_SET /* pre-ANSI systems may not define this; */
26#define SEEK_SET 0 /* if not, assume 0 is correct */ 26#define SEEK_SET 0 /* if not, assume 0 is correct */
27#endif 27#endif
28 28
29 29
30/* 30/*
31 * Memory allocation and freeing are controlled by the regular library 31 * Memory allocation and freeing are controlled by the regular library
32 * routines malloc() and free(). 32 * routines malloc() and free().
33 */ 33 */
34 34
35GLOBAL(void *) 35GLOBAL(void *)
36jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject) 36jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
37{ 37{
38 return (void *) malloc(sizeofobject); 38 return (void *) malloc(sizeofobject);
39} 39}
40 40
41GLOBAL(void) 41GLOBAL(void)
42jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject) 42jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
43{ 43{
44 free(object); 44 free(object);
45} 45}
46 46
47 47
48/* 48/*
49 * "Large" objects are treated the same as "small" ones. 49 * "Large" objects are treated the same as "small" ones.
50 * NB: although we include FAR keywords in the routine declarations, 50 * NB: although we include FAR keywords in the routine declarations,
51 * this file won't actually work in 80x86 small/medium model; at least, 51 * this file won't actually work in 80x86 small/medium model; at least,
52 * you probably won't be able to process useful-size images in only 64KB. 52 * you probably won't be able to process useful-size images in only 64KB.
53 */ 53 */
54 54
55GLOBAL(void FAR *) 55GLOBAL(void FAR *)
56jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject) 56jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
57{ 57{
58 return (void FAR *) malloc(sizeofobject); 58 return (void FAR *) malloc(sizeofobject);
59} 59}
60 60
61GLOBAL(void) 61GLOBAL(void)
62jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) 62jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
63{ 63{
64 free(object); 64 free(object);
65} 65}
66 66
67 67
68/* 68/*
69 * This routine computes the total memory space available for allocation. 69 * This routine computes the total memory space available for allocation.
70 * It's impossible to do this in a portable way; our current solution is 70 * It's impossible to do this in a portable way; our current solution is
71 * to make the user tell us (with a default value set at compile time). 71 * to make the user tell us (with a default value set at compile time).
72 * If you can actually get the available space, it's a good idea to subtract 72 * If you can actually get the available space, it's a good idea to subtract
73 * a slop factor of 5% or so. 73 * a slop factor of 5% or so.
74 */ 74 */
75 75
76#ifndef DEFAULT_MAX_MEM /* so can override from makefile */ 76#ifndef DEFAULT_MAX_MEM /* so can override from makefile */
77#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */ 77#define DEFAULT_MAX_MEM 1000000L /* default: one megabyte */
78#endif 78#endif
79 79
80GLOBAL(long) 80GLOBAL(long)
81jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, 81jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
82 long max_bytes_needed, long already_allocated) 82 long max_bytes_needed, long already_allocated)
83{ 83{
84 return cinfo->mem->max_memory_to_use - already_allocated; 84 return cinfo->mem->max_memory_to_use - already_allocated;
85} 85}
86 86
87 87
88/* 88/*
89 * Backing store (temporary file) management. 89 * Backing store (temporary file) management.
90 * Backing store objects are only used when the value returned by 90 * Backing store objects are only used when the value returned by
91 * jpeg_mem_available is less than the total space needed. You can dispense 91 * jpeg_mem_available is less than the total space needed. You can dispense
92 * with these routines if you have plenty of virtual memory; see jmemnobs.c. 92 * with these routines if you have plenty of virtual memory; see jmemnobs.c.
93 */ 93 */
94 94
95 95
96METHODDEF(void) 96METHODDEF(void)
97read_backing_store (j_common_ptr cinfo, backing_store_ptr info, 97read_backing_store (j_common_ptr cinfo, backing_store_ptr info,
98 void FAR * buffer_address, 98 void FAR * buffer_address,
99 long file_offset, long byte_count) 99 long file_offset, long byte_count)
100{ 100{
101 if (fseek(info->temp_file, file_offset, SEEK_SET)) 101 if (fseek(info->temp_file, file_offset, SEEK_SET))
102 ERREXIT(cinfo, JERR_TFILE_SEEK); 102 ERREXIT(cinfo, JERR_TFILE_SEEK);
103 if (JFREAD(info->temp_file, buffer_address, byte_count) 103 if (JFREAD(info->temp_file, buffer_address, byte_count)
104 != (size_t) byte_count) 104 != (size_t) byte_count)
105 ERREXIT(cinfo, JERR_TFILE_READ); 105 ERREXIT(cinfo, JERR_TFILE_READ);
106} 106}
107 107
108 108
109METHODDEF(void) 109METHODDEF(void)
110write_backing_store (j_common_ptr cinfo, backing_store_ptr info, 110write_backing_store (j_common_ptr cinfo, backing_store_ptr info,
111 void FAR * buffer_address, 111 void FAR * buffer_address,
112 long file_offset, long byte_count) 112 long file_offset, long byte_count)
113{ 113{
114 if (fseek(info->temp_file, file_offset, SEEK_SET)) 114 if (fseek(info->temp_file, file_offset, SEEK_SET))
115 ERREXIT(cinfo, JERR_TFILE_SEEK); 115 ERREXIT(cinfo, JERR_TFILE_SEEK);
116 if (JFWRITE(info->temp_file, buffer_address, byte_count) 116 if (JFWRITE(info->temp_file, buffer_address, byte_count)
117 != (size_t) byte_count) 117 != (size_t) byte_count)
118 ERREXIT(cinfo, JERR_TFILE_WRITE); 118 ERREXIT(cinfo, JERR_TFILE_WRITE);
119} 119}
120 120
121 121
122METHODDEF(void) 122METHODDEF(void)
123close_backing_store (j_common_ptr cinfo, backing_store_ptr info) 123close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
124{ 124{
125 fclose(info->temp_file); 125 fclose(info->temp_file);
126 /* Since this implementation uses tmpfile() to create the file, 126 /* Since this implementation uses tmpfile() to create the file,
127 * no explicit file deletion is needed. 127 * no explicit file deletion is needed.
128 */ 128 */
129} 129}
130 130
131 131
132/* 132/*
133 * Initial opening of a backing-store object. 133 * Initial opening of a backing-store object.
134 * 134 *
135 * This version uses tmpfile(), which constructs a suitable file name 135 * This version uses tmpfile(), which constructs a suitable file name
136 * behind the scenes. We don't have to use info->temp_name[] at all; 136 * behind the scenes. We don't have to use info->temp_name[] at all;
137 * indeed, we can't even find out the actual name of the temp file. 137 * indeed, we can't even find out the actual name of the temp file.
138 */ 138 */
139 139
140GLOBAL(void) 140GLOBAL(void)
141jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, 141jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
142 long total_bytes_needed) 142 long total_bytes_needed)
143{ 143{
144 if ((info->temp_file = tmpfile()) == NULL) 144 if ((info->temp_file = tmpfile()) == NULL)
145 ERREXITS(cinfo, JERR_TFILE_CREATE, ""); 145 ERREXITS(cinfo, JERR_TFILE_CREATE, "");
146 info->read_backing_store = read_backing_store; 146 info->read_backing_store = read_backing_store;
147 info->write_backing_store = write_backing_store; 147 info->write_backing_store = write_backing_store;
148 info->close_backing_store = close_backing_store; 148 info->close_backing_store = close_backing_store;
149} 149}
150 150
151 151
152/* 152/*
153 * These routines take care of any system-dependent initialization and 153 * These routines take care of any system-dependent initialization and
154 * cleanup required. 154 * cleanup required.
155 */ 155 */
156 156
157GLOBAL(long) 157GLOBAL(long)
158jpeg_mem_init (j_common_ptr cinfo) 158jpeg_mem_init (j_common_ptr cinfo)
159{ 159{
160 return DEFAULT_MAX_MEM; /* default for max_memory_to_use */ 160 return DEFAULT_MAX_MEM; /* default for max_memory_to_use */
161} 161}
162 162
163GLOBAL(void) 163GLOBAL(void)
164jpeg_mem_term (j_common_ptr cinfo) 164jpeg_mem_term (j_common_ptr cinfo)
165{ 165{
166 /* no work */ 166 /* no work */
167} 167}