Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / compiler / libjpeg / main / jmemnobs.c
blobe5a97f00af779a02ef374838e5ed6ced3d1b2ced
1 /*
2 $Id$
4 Changes:
5 1.4.03: Use AllocVec/FreeVec instead of malloc/free because of problems in jpeg.datatype
6 */
8 /*
9 * jmemnobs.c
11 * Copyright (C) 1992-1996, Thomas G. Lane.
12 * This file is part of the Independent JPEG Group's software.
13 * For conditions of distribution and use, see the accompanying README file.
15 * This file provides a really simple implementation of the system-
16 * dependent portion of the JPEG memory manager. This implementation
17 * assumes that no backing-store files are needed: all required space
18 * can be obtained from malloc().
19 * This is very portable in the sense that it'll compile on almost anything,
20 * but you'd better have lots of main memory (or virtual memory) if you want
21 * to process big images.
22 * Note that the max_memory_to_use option is ignored by this implementation.
25 #include <proto/exec.h>
26 #include <exec/memory.h>
28 #define JPEG_INTERNALS
29 #include "jinclude.h"
30 #include "jpeglib.h"
31 #include "jmemsys.h" /* import the system-dependent declarations */
33 #include "debug.h"
35 #define malloc(size) AllocVec((size), MEMF_ANY)
36 #define free(mem) FreeVec(mem)
38 #ifndef HAVE_STDLIB_H /* <stdlib.h> should declare malloc(),free() */
39 extern void * malloc JPP((size_t size));
40 extern void free JPP((void *ptr));
41 #endif
45 * Memory allocation and freeing are controlled by the regular library
46 * routines malloc() and free().
49 JGLOBAL(void *)
50 jpeg_get_small (j_common_ptr cinfo, size_t sizeofobject)
52 D(bug("libjpeg: alloc small %ld\n", (long)sizeofobject));
53 return (void *) malloc(sizeofobject);
56 JGLOBAL(void)
57 jpeg_free_small (j_common_ptr cinfo, void * object, size_t sizeofobject)
59 free(object);
64 * "Large" objects are treated the same as "small" ones.
65 * NB: although we include FAR keywords in the routine declarations,
66 * this file won't actually work in 80x86 small/medium model; at least,
67 * you probably won't be able to process useful-size images in only 64KB.
70 JGLOBAL(void FAR *)
71 jpeg_get_large (j_common_ptr cinfo, size_t sizeofobject)
73 D(bug("libjpeg: alloc large %ld\n", (long)sizeofobject));
74 return (void FAR *) malloc(sizeofobject);
77 JGLOBAL(void)
78 jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject)
80 free(object);
85 * This routine computes the total memory space available for allocation.
86 * Here we always say, "we got all you want bud!"
89 JGLOBAL(long)
90 jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed,
91 long max_bytes_needed, long already_allocated)
93 return max_bytes_needed;
98 * Backing store (temporary file) management.
99 * Since jpeg_mem_available always promised the moon,
100 * this should never be called and we can just error out.
103 JGLOBAL(void)
104 jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info,
105 long total_bytes_needed)
107 ERREXIT(cinfo, JERR_NO_BACKING_STORE);
112 * These routines take care of any system-dependent initialization and
113 * cleanup required. Here, there isn't any.
116 JGLOBAL(long)
117 jpeg_mem_init (j_common_ptr cinfo)
119 return 0; /* just set max_memory_to_use to 0 */
122 JGLOBAL(void)
123 jpeg_mem_term (j_common_ptr cinfo)
125 /* no work */