summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/gzip/ftgzip.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/freetype/src/gzip/ftgzip.c')
-rw-r--r--src/3rdparty/freetype/src/gzip/ftgzip.c115
1 files changed, 54 insertions, 61 deletions
diff --git a/src/3rdparty/freetype/src/gzip/ftgzip.c b/src/3rdparty/freetype/src/gzip/ftgzip.c
index 5e78bc6f8d..ca6a2aabe6 100644
--- a/src/3rdparty/freetype/src/gzip/ftgzip.c
+++ b/src/3rdparty/freetype/src/gzip/ftgzip.c
@@ -8,7 +8,7 @@
* parse compressed PCF fonts, as found with many X11 server
* distributions.
*
- * Copyright (C) 2002-2019 by
+ * Copyright (C) 2002-2023 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used,
@@ -20,15 +20,14 @@
*/
-#include <ft2build.h>
-#include FT_INTERNAL_MEMORY_H
-#include FT_INTERNAL_STREAM_H
-#include FT_INTERNAL_DEBUG_H
-#include FT_GZIP_H
+#include <freetype/internal/ftmemory.h>
+#include <freetype/internal/ftstream.h>
+#include <freetype/internal/ftdebug.h>
+#include <freetype/ftgzip.h>
#include FT_CONFIG_STANDARD_LIBRARY_H
-#include FT_MODULE_ERRORS_H
+#include <freetype/ftmoderr.h>
#undef FTERRORS_H_
@@ -36,7 +35,7 @@
#define FT_ERR_PREFIX Gzip_Err_
#define FT_ERR_BASE FT_Mod_Err_Gzip
-#include FT_ERRORS_H
+#include <freetype/fterrors.h>
#ifdef FT_CONFIG_OPTION_USE_ZLIB
@@ -70,10 +69,14 @@
/* */
/* so that configuration with `FT_CONFIG_OPTION_SYSTEM_ZLIB' might */
/* include the wrong `zconf.h' file, leading to errors. */
-#include "zlib.h"
-#undef SLOW
-#define SLOW 1 /* we can't use asm-optimized sources here! */
+#define ZEXPORT
+ /* prevent zlib functions from being visible outside their object files */
+#define ZEXTERN static
+
+#define HAVE_MEMCPY 1
+#define Z_SOLO 1
+#define Z_FREETYPE 1
#if defined( _MSC_VER ) /* Visual C++ (and Intel C++) */
/* We disable the warning `conversion from XXX to YYY, */
@@ -84,24 +87,25 @@
#pragma warning( disable : 4244 )
#endif /* _MSC_VER */
- /* Urgh. `inflate_mask' must not be declared twice -- C++ doesn't like
- this. We temporarily disable it and load all necessary header files. */
-#define NO_INFLATE_MASK
-#include "zutil.h"
-#include "inftrees.h"
-#include "infblock.h"
-#include "infcodes.h"
-#include "infutil.h"
-#undef NO_INFLATE_MASK
-
- /* infutil.c must be included before infcodes.c */
+#if defined( __GNUC__ )
+#pragma GCC diagnostic push
+#ifndef __cplusplus
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
+#endif
+#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#pragma GCC diagnostic ignored "-Wredundant-decls"
+#endif
+
#include "zutil.c"
-#include "inftrees.c"
-#include "infutil.c"
-#include "infcodes.c"
-#include "infblock.c"
+#include "inffast.c"
#include "inflate.c"
+#include "inftrees.c"
#include "adler32.c"
+#include "crc32.c"
+
+#if defined( __GNUC__ )
+#pragma GCC diagnostic pop
+#endif
#if defined( _MSC_VER )
#pragma warning( pop )
@@ -122,48 +126,32 @@
'malloc/free' */
static voidpf
- ft_gzip_alloc( FT_Memory memory,
- uInt items,
- uInt size )
+ ft_gzip_alloc( voidpf opaque,
+ uInt items,
+ uInt size )
{
- FT_ULong sz = (FT_ULong)size * items;
+ FT_Memory memory = (FT_Memory)opaque;
+ FT_ULong sz = (FT_ULong)size * items;
FT_Error error;
- FT_Pointer p = NULL;
+ FT_Pointer p = NULL;
- (void)FT_ALLOC( p, sz );
+ /* allocate and zero out */
+ FT_MEM_ALLOC( p, sz );
return p;
}
static void
- ft_gzip_free( FT_Memory memory,
- voidpf address )
+ ft_gzip_free( voidpf opaque,
+ voidpf address )
{
- FT_MEM_FREE( address );
- }
-
-
-#if !defined( FT_CONFIG_OPTION_SYSTEM_ZLIB ) && !defined( USE_ZLIB_ZCALLOC )
+ FT_Memory memory = (FT_Memory)opaque;
- local voidpf
- zcalloc ( voidpf opaque,
- unsigned items,
- unsigned size )
- {
- return ft_gzip_alloc( (FT_Memory)opaque, items, size );
- }
- local void
- zcfree( voidpf opaque,
- voidpf ptr )
- {
- ft_gzip_free( (FT_Memory)opaque, ptr );
+ FT_MEM_FREE( address );
}
-#endif /* !SYSTEM_ZLIB && !USE_ZLIB_ZCALLOC */
-
-
/***************************************************************************/
/***************************************************************************/
/***** *****/
@@ -305,8 +293,8 @@
}
/* initialize zlib -- there is no zlib header in the compressed stream */
- zstream->zalloc = (alloc_func)ft_gzip_alloc;
- zstream->zfree = (free_func) ft_gzip_free;
+ zstream->zalloc = ft_gzip_alloc;
+ zstream->zfree = ft_gzip_free;
zstream->opaque = stream->memory;
zstream->avail_in = 0;
@@ -463,12 +451,13 @@
FT_ULong count )
{
FT_Error error = FT_Err_Ok;
- FT_ULong delta;
for (;;)
{
- delta = (FT_ULong)( zip->limit - zip->cursor );
+ FT_ULong delta = (FT_ULong)( zip->limit - zip->cursor );
+
+
if ( delta >= count )
delta = count;
@@ -672,7 +661,7 @@
FT_Byte* zip_buff = NULL;
- if ( !FT_ALLOC( zip_buff, zip_size ) )
+ if ( !FT_QALLOC( zip_buff, zip_size ) )
{
FT_ULong count;
@@ -742,11 +731,12 @@
stream.next_out = output;
stream.avail_out = (uInt)*output_len;
- stream.zalloc = (alloc_func)ft_gzip_alloc;
- stream.zfree = (free_func) ft_gzip_free;
+ stream.zalloc = ft_gzip_alloc;
+ stream.zfree = ft_gzip_free;
stream.opaque = memory;
err = inflateInit2( &stream, MAX_WBITS|32 );
+
if ( err != Z_OK )
return FT_THROW( Invalid_Argument );
@@ -773,6 +763,9 @@
if ( err == Z_DATA_ERROR )
return FT_THROW( Invalid_Table );
+ if ( err == Z_NEED_DICT )
+ return FT_THROW( Invalid_Table );
+
return FT_Err_Ok;
}