rev |
line source |
nuclear@1
|
1 /*
|
nuclear@1
|
2 * jmemnobs.c
|
nuclear@1
|
3 *
|
nuclear@1
|
4 * Copyright (C) 1992-1996, Thomas G. Lane.
|
nuclear@1
|
5 * This file is part of the Independent JPEG Group's software.
|
nuclear@1
|
6 * For conditions of distribution and use, see the accompanying README file.
|
nuclear@1
|
7 *
|
nuclear@1
|
8 * This file provides a really simple implementation of the system-
|
nuclear@1
|
9 * dependent portion of the JPEG memory manager. This implementation
|
nuclear@1
|
10 * assumes that no backing-store files are needed: all required space
|
nuclear@1
|
11 * can be obtained from malloc().
|
nuclear@1
|
12 * This is very portable in the sense that it'll compile on almost anything,
|
nuclear@1
|
13 * but you'd better have lots of main memory (or virtual memory) if you want
|
nuclear@1
|
14 * to process big images.
|
nuclear@1
|
15 * Note that the max_memory_to_use option is ignored by this implementation.
|
nuclear@1
|
16 */
|
nuclear@1
|
17
|
nuclear@1
|
18 #define JPEG_INTERNALS
|
nuclear@1
|
19 #include "jinclude.h"
|
nuclear@1
|
20 #include "jpeglib.h"
|
nuclear@1
|
21 #include "jmemsys.h" /* import the system-dependent declarations */
|
nuclear@1
|
22
|
nuclear@1
|
23 #ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
|
nuclear@1
|
24 extern void * malloc JPP((size_t size));
|
nuclear@1
|
25 extern void free JPP((void *ptr));
|
nuclear@1
|
26 #endif
|
nuclear@1
|
27
|
nuclear@1
|
28
|
nuclear@1
|
29 /*
|
nuclear@1
|
30 * Memory allocation and freeing are controlled by the regular library
|
nuclear@1
|
31 * routines malloc() and free().
|
nuclear@1
|
32 */
|
nuclear@1
|
33
|
nuclear@1
|
34 GLOBAL(void *)
|
nuclear@1
|
35 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
|
nuclear@1
|
36 {
|
nuclear@1
|
37 return (void *) malloc(sizeofobject);
|
nuclear@1
|
38 }
|
nuclear@1
|
39
|
nuclear@1
|
40 GLOBAL(void)
|
nuclear@1
|
41 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
|
nuclear@1
|
42 {
|
nuclear@1
|
43 free(object);
|
nuclear@1
|
44 }
|
nuclear@1
|
45
|
nuclear@1
|
46
|
nuclear@1
|
47 /*
|
nuclear@1
|
48 * "Large" objects are treated the same as "small" ones.
|
nuclear@1
|
49 * NB: although we include FAR keywords in the routine declarations,
|
nuclear@1
|
50 * this file won't actually work in 80x86 small/medium model; at least,
|
nuclear@1
|
51 * you probably won't be able to process useful-size images in only 64KB.
|
nuclear@1
|
52 */
|
nuclear@1
|
53
|
nuclear@1
|
54 GLOBAL(void FAR *)
|
nuclear@1
|
55 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
|
nuclear@1
|
56 {
|
nuclear@1
|
57 return (void FAR *) malloc(sizeofobject);
|
nuclear@1
|
58 }
|
nuclear@1
|
59
|
nuclear@1
|
60 GLOBAL(void)
|
nuclear@1
|
61 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
|
nuclear@1
|
62 {
|
nuclear@1
|
63 free(object);
|
nuclear@1
|
64 }
|
nuclear@1
|
65
|
nuclear@1
|
66
|
nuclear@1
|
67 /*
|
nuclear@1
|
68 * This routine computes the total memory space available for allocation.
|
nuclear@1
|
69 * Here we always say, "we got all you want bud!"
|
nuclear@1
|
70 */
|
nuclear@1
|
71
|
nuclear@1
|
72 GLOBAL(long)
|
nuclear@1
|
73 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
|
nuclear@1
|
74 long max_bytes_needed, long already_allocated)
|
nuclear@1
|
75 {
|
nuclear@1
|
76 return max_bytes_needed;
|
nuclear@1
|
77 }
|
nuclear@1
|
78
|
nuclear@1
|
79
|
nuclear@1
|
80 /*
|
nuclear@1
|
81 * Backing store (temporary file) management.
|
nuclear@1
|
82 * Since jpeg_mem_available always promised the moon,
|
nuclear@1
|
83 * this should never be called and we can just error out.
|
nuclear@1
|
84 */
|
nuclear@1
|
85
|
nuclear@1
|
86 GLOBAL(void)
|
nuclear@1
|
87 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
|
nuclear@1
|
88 long total_bytes_needed)
|
nuclear@1
|
89 {
|
nuclear@1
|
90 ERREXIT(cinfo, JERR_NO_BACKING_STORE);
|
nuclear@1
|
91 }
|
nuclear@1
|
92
|
nuclear@1
|
93
|
nuclear@1
|
94 /*
|
nuclear@1
|
95 * These routines take care of any system-dependent initialization and
|
nuclear@1
|
96 * cleanup required. Here, there isn't any.
|
nuclear@1
|
97 */
|
nuclear@1
|
98
|
nuclear@1
|
99 GLOBAL(long)
|
nuclear@1
|
100 jpeg_mem_init (j_common_ptr cinfo)
|
nuclear@1
|
101 {
|
nuclear@1
|
102 return 0; /* just set max_memory_to_use to 0 */
|
nuclear@1
|
103 }
|
nuclear@1
|
104
|
nuclear@1
|
105 GLOBAL(void)
|
nuclear@1
|
106 jpeg_mem_term (j_common_ptr cinfo)
|
nuclear@1
|
107 {
|
nuclear@1
|
108 /* no work */
|
nuclear@1
|
109 }
|