Skip to content

Commit

Permalink
Fix PHP 7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
remicollet committed Mar 30, 2015
1 parent fd868dc commit d2f0184
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions framework/lz4/horde_lz4.c
Expand Up @@ -87,7 +87,7 @@ PHP_FUNCTION(horde_lz4_compress)
RETURN_FALSE;
}

data_len = Z_STRLEN_P(data);
data_len = (int)Z_STRLEN_P(data);

output = (char *)emalloc(LZ4_compressBound(data_len) + header_offset);
if (!output) {
Expand All @@ -107,7 +107,7 @@ PHP_FUNCTION(horde_lz4_compress)
if (output_len <= 0) {
RETVAL_FALSE;
} else {
RETVAL_STRINGL(output, output_len + header_offset, 1);
HORDE_LZ4_RETSTRL(output, output_len + header_offset);
}

efree(output);
Expand Down Expand Up @@ -155,7 +155,7 @@ PHP_FUNCTION(horde_lz4_uncompress)
if (output_len <= 0) {
RETVAL_FALSE;
} else {
RETVAL_STRINGL(output, data_len, 1);
HORDE_LZ4_RETSTRL(output, data_len);
}

efree(output);
Expand Down
7 changes: 7 additions & 0 deletions framework/lz4/horde_lz4.h
Expand Up @@ -23,4 +23,11 @@ PHP_MINFO_FUNCTION(horde_lz4);
PHP_FUNCTION(horde_lz4_compress);
PHP_FUNCTION(horde_lz4_uncompress);

#if PHP_MAJOR_VERSION < 7
#define HORDE_LZ4_RETSTRL(a,l) RETURN_STRINGL(a,l,1)
#else
typedef size_t strsize;
#define HORDE_LZ4_RETSTRL(a,l) RETURN_STRINGL(a,l)
#endif

#endif /* PHP_HORDE_LZ4_H */

0 comments on commit d2f0184

Please sign in to comment.