libc/lzf: lzf_compress() now expects the hash table as user allocated input parmeter rather than declaring the huge array on the stack.
This commit is contained in:
parent
9acfbd2163
commit
0ab037e6b4
@ -50,7 +50,7 @@
|
||||
typedef const uint8_t *lzf_hslot_t;
|
||||
#endif
|
||||
|
||||
typedef lzf_hslot_t LZF_STATE[1 << HLOG];
|
||||
typedef lzf_hslot_t lzf_state_t[1 << HLOG];
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
@ -74,15 +74,11 @@ typedef lzf_hslot_t LZF_STATE[1 << HLOG];
|
||||
* original data when decompressed using lzf_decompress.
|
||||
*
|
||||
* The buffers must not be overlapping.
|
||||
*
|
||||
* If the option LZF_STATE_ARG is enabled, an extra argument must be
|
||||
* supplied which is not reflected in this header file. Refer to lzfP.h
|
||||
* and lzf_c.c.
|
||||
*/
|
||||
|
||||
unsigned int lzf_compress(FAR const void *const in_data,
|
||||
unsigned int in_len, FAR void *out_data,
|
||||
unsigned int out_len);
|
||||
unsigned int out_len, lzf_state_t htab);
|
||||
|
||||
/* Decompress data compressed with some version of the lzf_compress
|
||||
* function and stored at location in_data and length in_len. The result
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* libc/lzf/lzf_c.c
|
||||
* libc/lzf/lzf.h
|
||||
*
|
||||
* Copyright (c) 2000-2007 Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||
*
|
||||
@ -26,8 +26,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __LIBC_LZF_LZFP_H
|
||||
#define __LIBC_LZF_LZFP_H 1
|
||||
#ifndef __LIBC_LZF_LZF_H
|
||||
#define __LIBC_LZF_LZF_H 1
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@ -63,15 +63,6 @@ using namespace std;
|
||||
# define INIT_HTAB 0
|
||||
#endif
|
||||
|
||||
/* Whether to pass the LZF_STATE variable as argument, or allocate it
|
||||
* on the stack. For small-stack environments, define this to 1.
|
||||
* NOTE: this breaks the prototype in lzf.h.
|
||||
*/
|
||||
|
||||
#ifndef LZF_STATE_ARG
|
||||
# define LZF_STATE_ARG 0
|
||||
#endif
|
||||
|
||||
/* Whether to add extra checks for input validity in lzf_decompress
|
||||
* and return EINVAL if the input stream has been corrupted. This
|
||||
* only shields against overflowing the input buffer and will not
|
||||
@ -99,4 +90,4 @@ using namespace std;
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#endif /* __LIBC_LZF_LZFP_H */
|
||||
#endif /* __LIBC_LZF_LZF_H */
|
@ -30,7 +30,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "lzf/lzfP.h"
|
||||
#include "lzf/lzf.h"
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
|
||||
@ -100,16 +100,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
unsigned int lzf_compress(FAR const void *const in_data, unsigned int in_len,
|
||||
FAR void *out_data, unsigned int out_len
|
||||
#if LZF_STATE_ARG
|
||||
, LZF_STATE htab
|
||||
#endif
|
||||
)
|
||||
unsigned int lzf_compress(FAR const void *const in_data,
|
||||
unsigned int in_len, FAR void *out_data,
|
||||
unsigned int out_len, lzf_state_t htab)
|
||||
{
|
||||
#if !LZF_STATE_ARG
|
||||
LZF_STATE htab;
|
||||
#endif
|
||||
FAR const uint8_t *ip = (const uint8_t *)in_data;
|
||||
FAR uint8_t *op = (uint8_t *)out_data;
|
||||
FAR const uint8_t *in_end = ip + in_len;
|
||||
|
@ -30,7 +30,7 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "lzf/lzfP.h"
|
||||
#include "lzf/lzf.h"
|
||||
|
||||
#ifdef CONFIG_LIBC_LZF
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user