source: golgotha/src/i4/loaders/jpg/jmemnobs.cc @ 608

Last change on this file since 608 was 80, checked in by Sam Hocevar, 15 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 3.4 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9/*
10 * jmemnobs.c
11 *
12 * Copyright (C) 1992-1996, Thomas G. Lane.
13 * This file is part of the Independent JPEG Group's software.
14 * For conditions of distribution and use, see the accompanying README file.
15 *
16 * This file provides a really simple implementation of the system-
17 * dependent portion of the JPEG memory manager.  This implementation
18 * assumes that no backing-store files are needed: all required space
19 * can be obtained from malloc().
20 * This is very portable in the sense that it'll compile on almost anything,
21 * but you'd better have lots of main memory (or virtual memory) if you want
22 * to process big images.
23 * Note that the max_memory_to_use option is ignored by this implementation.
24 */
25
26#define JPEG_INTERNALS
27#include "loaders/jpg/jinclude.h"
28#include "loaders/jpg/jpeglib.h"
29#include "loaders/jpg/jmemsys.h"                /* import the system-dependent declarations */
30#include "memory/malloc.hh"
31
32#ifndef HAVE_STDLIB_H           /* <stdlib.h> should declare malloc(),free() */
33extern void * malloc JPP((size_t size));
34extern void free JPP((void *ptr));
35#endif
36
37
38/*
39 * Memory allocation and freeing are controlled by the regular library
40 * routines malloc() and free().
41 */
42
43GLOBAL(void *)
44jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
45{
46  return (void *) i4_malloc(sizeofobject, "jpeg_get_small");
47}
48
49GLOBAL(void)
50jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
51{
52  i4_free(object);
53}
54
55
56/*
57 * "Large" objects are treated the same as "small" ones.
58 * NB: although we include FAR keywords in the routine declarations,
59 * this file won't actually work in 80x86 small/medium model; at least,
60 * you probably won't be able to process useful-size images in only 64KB.
61 */
62
63GLOBAL(void FAR *)
64jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
65{
66  return (void FAR *) i4_malloc(sizeofobject, "jpeg_get_large");
67}
68
69GLOBAL(void)
70jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
71{
72  i4_free(object);
73}
74
75
76/*
77 * This routine computes the total memory space available for allocation.
78 * Here we always say, "we got all you want bud!"
79 */
80
81GLOBAL(long)
82jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
83                    long max_bytes_needed, long already_allocated)
84{
85  return max_bytes_needed;
86}
87
88
89/*
90 * Backing store (temporary file) management.
91 * Since jpeg_mem_available always promised the moon,
92 * this should never be called and we can just error out.
93 */
94
95GLOBAL(void)
96jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
97                         long total_bytes_needed)
98{
99  ERREXIT(cinfo, JERR_NO_BACKING_STORE);
100}
101
102
103/*
104 * These routines take care of any system-dependent initialization and
105 * cleanup required.  Here, there isn't any.
106 */
107
108GLOBAL(long)
109jpeg_mem_init (j_common_ptr cinfo)
110{
111  return 0;                     /* just set max_memory_to_use to 0 */
112}
113
114GLOBAL(void)
115jpeg_mem_term (j_common_ptr cinfo)
116{
117  /* no work */
118}
Note: See TracBrowser for help on using the repository browser.