Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #define JPEG_INTERNALS
00016 #include "jinclude.h"
00017 #include "jpeglib.h"
00018 #include "jmemsys.h"
00019
00020 #ifndef HAVE_STDLIB_H
00021 extern void * malloc JPP((size_t size));
00022 extern void free JPP((void *ptr));
00023 #endif
00024
00025 #ifndef SEEK_SET
00026 #define SEEK_SET 0
00027 #endif
00028
00029
00030
00031
00032
00033
00034
00035 GLOBAL(void *)
00036 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
00037 {
00038 return (void *) malloc(sizeofobject);
00039 }
00040
00041 GLOBAL(void)
00042 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
00043 {
00044 free(object);
00045 }
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 GLOBAL(void FAR *)
00056 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
00057 {
00058 return (void FAR *) malloc(sizeofobject);
00059 }
00060
00061 GLOBAL(void)
00062 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
00063 {
00064 free(object);
00065 }
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 #ifndef DEFAULT_MAX_MEM
00077 #define DEFAULT_MAX_MEM 1000000L
00078 #endif
00079
00080 GLOBAL(long)
00081 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
00082 long max_bytes_needed, long already_allocated)
00083 {
00084 return cinfo->mem->max_memory_to_use - already_allocated;
00085 }
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 METHODDEF(void)
00097 read_backing_store (j_common_ptr cinfo, backing_store_ptr info,
00098 void FAR * buffer_address,
00099 long file_offset, long byte_count)
00100 {
00101 if (fseek(info->temp_file, file_offset, SEEK_SET))
00102 ERREXIT(cinfo, JERR_TFILE_SEEK);
00103 if (JFREAD(info->temp_file, buffer_address, byte_count)
00104 != (size_t) byte_count)
00105 ERREXIT(cinfo, JERR_TFILE_READ);
00106 }
00107
00108
00109 METHODDEF(void)
00110 write_backing_store (j_common_ptr cinfo, backing_store_ptr info,
00111 void FAR * buffer_address,
00112 long file_offset, long byte_count)
00113 {
00114 if (fseek(info->temp_file, file_offset, SEEK_SET))
00115 ERREXIT(cinfo, JERR_TFILE_SEEK);
00116 if (JFWRITE(info->temp_file, buffer_address, byte_count)
00117 != (size_t) byte_count)
00118 ERREXIT(cinfo, JERR_TFILE_WRITE);
00119 }
00120
00121
00122 METHODDEF(void)
00123 close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
00124 {
00125 fclose(info->temp_file);
00126
00127
00128
00129 }
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 GLOBAL(void)
00141 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
00142 long total_bytes_needed)
00143 {
00144 if ((info->temp_file = tmpfile()) == NULL)
00145 ERREXITS(cinfo, JERR_TFILE_CREATE, "");
00146 info->read_backing_store = read_backing_store;
00147 info->write_backing_store = write_backing_store;
00148 info->close_backing_store = close_backing_store;
00149 }
00150
00151
00152
00153
00154
00155
00156
00157 GLOBAL(long)
00158 jpeg_mem_init (j_common_ptr cinfo)
00159 {
00160 return DEFAULT_MAX_MEM;
00161 }
00162
00163 GLOBAL(void)
00164 jpeg_mem_term (j_common_ptr cinfo)
00165 {
00166
00167 }