ReactOS  0.4.15-dev-509-g96a357b
jmemname.c File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jmemsys.h"
Include dependency graph for jmemname.c:

Go to the source code of this file.

Macros

#define JPEG_INTERNALS
 
#define SEEK_SET   0 /* if not, assume 0 is correct */
 
#define READ_BINARY   "rb"
 
#define RW_BINARY   "w+b"
 
#define TEMP_DIRECTORY   "/usr/tmp/" /* recommended setting for Unix */
 
#define TEMP_FILE_NAME   "%sJPG%dXXXXXX"
 
#define DEFAULT_MAX_MEM   1000000L /* default: one megabyte */
 

Functions

void *malloc JPP ((size_t size))
 
void free JPP ((void *ptr))
 
 select_file_name (char *fname)
 
 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
 
 jpeg_free_small (j_common_ptr cinfo, void *object, size_t sizeofobject)
 
 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
 
 jpeg_free_large (j_common_ptr cinfo, void FAR *object, size_t sizeofobject)
 
 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, long max_bytes_needed, long already_allocated)
 
 read_backing_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
 
 write_backing_store (j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
 
 close_backing_store (j_common_ptr cinfo, backing_store_ptr info)
 
 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, long total_bytes_needed)
 
 jpeg_mem_init (j_common_ptr cinfo)
 
 jpeg_mem_term (j_common_ptr cinfo)
 

Variables

static int next_file_num
 

Macro Definition Documentation

◆ DEFAULT_MAX_MEM

#define DEFAULT_MAX_MEM   1000000L /* default: one megabyte */

Definition at line 184 of file jmemname.c.

◆ JPEG_INTERNALS

#define JPEG_INTERNALS

Definition at line 15 of file jmemname.c.

◆ READ_BINARY

#define READ_BINARY   "rb"

Definition at line 37 of file jmemname.c.

◆ RW_BINARY

#define RW_BINARY   "w+b"

Definition at line 38 of file jmemname.c.

◆ SEEK_SET

#define SEEK_SET   0 /* if not, assume 0 is correct */

Definition at line 26 of file jmemname.c.

◆ TEMP_DIRECTORY

#define TEMP_DIRECTORY   "/usr/tmp/" /* recommended setting for Unix */

Definition at line 70 of file jmemname.c.

◆ TEMP_FILE_NAME

#define TEMP_FILE_NAME   "%sJPG%dXXXXXX"

Definition at line 122 of file jmemname.c.

Function Documentation

◆ close_backing_store()

close_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info 
)

Definition at line 230 of file jmemname.c.

231 {
232  fclose(info->temp_file); /* close the file */
233  unlink(info->temp_name); /* delete the file */
234 /* If your system doesn't have unlink(), use remove() instead.
235  * remove() is the ANSI-standard name for this function, but if
236  * your system was ANSI you'd be using jmemansi.c, right?
237  */
238  TRACEMSS(cinfo, 1, JTRC_TFILE_CLOSE, info->temp_name);
239 }
#define unlink
Definition: syshdrs.h:54
#define TRACEMSS(cinfo, lvl, code, str)
Definition: jerror.h:299
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)

Referenced by jpeg_open_backing_store().

◆ jpeg_free_large()

jpeg_free_large ( j_common_ptr  cinfo,
void FAR object,
size_t  sizeofobject 
)

Definition at line 169 of file jmemname.c.

170 {
171  free(object);
172 }
#define free
Definition: debug_ros.c:5

◆ jpeg_free_small()

jpeg_free_small ( j_common_ptr  cinfo,
void object,
size_t  sizeofobject 
)

Definition at line 149 of file jmemname.c.

150 {
151  free(object);
152 }
#define free
Definition: debug_ros.c:5

◆ jpeg_get_large()

jpeg_get_large ( j_common_ptr  cinfo,
size_t  sizeofobject 
)

Definition at line 163 of file jmemname.c.

164 {
165  return (void FAR *) malloc(sizeofobject);
166 }
size_t sizeofobject
Definition: jmemsys.h:47
#define FAR
Definition: guiddef.h:36
#define malloc
Definition: debug_ros.c:4

◆ jpeg_get_small()

jpeg_get_small ( j_common_ptr  cinfo,
size_t  sizeofobject 
)

Definition at line 143 of file jmemname.c.

144 {
145  return (void *) malloc(sizeofobject);
146 }
size_t sizeofobject
Definition: jmemsys.h:47
#define malloc
Definition: debug_ros.c:4

◆ jpeg_mem_available()

jpeg_mem_available ( j_common_ptr  cinfo,
long  min_bytes_needed,
long  max_bytes_needed,
long  already_allocated 
)

Definition at line 188 of file jmemname.c.

190 {
191  return cinfo->mem->max_memory_to_use - already_allocated;
192 }
long long long already_allocated
Definition: jmemsys.h:104

◆ jpeg_mem_init()

jpeg_mem_init ( j_common_ptr  cinfo)

Definition at line 266 of file jmemname.c.

267 {
268  next_file_num = 0; /* initialize temp file name generator */
269  return DEFAULT_MAX_MEM; /* default for max_memory_to_use */
270 }
#define DEFAULT_MAX_MEM
Definition: jmemname.c:184
static int next_file_num
Definition: jmemname.c:73

◆ jpeg_mem_term()

jpeg_mem_term ( j_common_ptr  cinfo)

Definition at line 273 of file jmemname.c.

274 {
275  /* no work */
276 }

◆ jpeg_open_backing_store()

jpeg_open_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
long  total_bytes_needed 
)

Definition at line 247 of file jmemname.c.

249 {
250  select_file_name(info->temp_name);
251  if ((info->temp_file = fopen(info->temp_name, RW_BINARY)) == NULL)
252  ERREXITS(cinfo, JERR_TFILE_CREATE, info->temp_name);
253  info->read_backing_store = read_backing_store;
254  info->write_backing_store = write_backing_store;
255  info->close_backing_store = close_backing_store;
256  TRACEMSS(cinfo, 1, JTRC_TFILE_OPEN, info->temp_name);
257 }
#define RW_BINARY
Definition: jmemname.c:38
select_file_name(char *fname)
Definition: jmemname.c:126
smooth NULL
Definition: ftsmooth.c:416
read_backing_store(j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
Definition: jmemname.c:204
#define TRACEMSS(cinfo, lvl, code, str)
Definition: jerror.h:299
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
write_backing_store(j_common_ptr cinfo, backing_store_ptr info, void FAR *buffer_address, long file_offset, long byte_count)
Definition: jmemname.c:217
close_backing_store(j_common_ptr cinfo, backing_store_ptr info)
Definition: jmemname.c:230
#define ERREXITS(cinfo, code, str)
Definition: jerror.h:243

◆ JPP() [1/2]

void* malloc JPP ( (size_t size )

◆ JPP() [2/2]

void free JPP ( (void *ptr )

◆ read_backing_store()

read_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR buffer_address,
long  file_offset,
long  byte_count 
)

Definition at line 204 of file jmemname.c.

207 {
208  if (fseek(info->temp_file, file_offset, SEEK_SET))
209  ERREXIT(cinfo, JERR_TFILE_SEEK);
210  if (JFREAD(info->temp_file, buffer_address, byte_count)
211  != (size_t) byte_count)
212  ERREXIT(cinfo, JERR_TFILE_READ);
213 }
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
#define JFREAD(file, buf, sizeofbuf)
Definition: jinclude.h:92
#define SEEK_SET
Definition: jmemname.c:26
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)

Referenced by jpeg_open_backing_store().

◆ select_file_name()

select_file_name ( char fname)

Definition at line 126 of file jmemname.c.

127 {
128  next_file_num++; /* advance counter */
130  mktemp(fname); /* make sure file name is unique */
131  /* mktemp replaces the trailing XXXXXX with a unique string of characters */
132 }
#define TEMP_DIRECTORY
Definition: jmemname.c:70
#define sprintf(buf, format,...)
Definition: sprintf.c:55
_CRTIMP char *__cdecl mktemp(_Inout_z_ char *_TemplateName)
#define TEMP_FILE_NAME
Definition: jmemname.c:122
static int next_file_num
Definition: jmemname.c:73

Referenced by jpeg_open_backing_store().

◆ write_backing_store()

write_backing_store ( j_common_ptr  cinfo,
backing_store_ptr  info,
void FAR buffer_address,
long  file_offset,
long  byte_count 
)

Definition at line 217 of file jmemname.c.

220 {
221  if (fseek(info->temp_file, file_offset, SEEK_SET))
222  ERREXIT(cinfo, JERR_TFILE_SEEK);
223  if (JFWRITE(info->temp_file, buffer_address, byte_count)
224  != (size_t) byte_count)
225  ERREXIT(cinfo, JERR_TFILE_WRITE);
226 }
#define ERREXIT(msg)
Definition: rdjpgcom.c:72
#define JFWRITE(file, buf, sizeofbuf)
Definition: jinclude.h:94
#define SEEK_SET
Definition: jmemname.c:26
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)

Referenced by jpeg_open_backing_store().

Variable Documentation

◆ next_file_num

int next_file_num
static

Definition at line 73 of file jmemname.c.

Referenced by jpeg_mem_init(), and select_file_name().