media/libjpeg/jmemnobs.c

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial