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