Skip to content

Commit 468487d

Browse files
committed
Fix build against libmemcached versions before 0.39.
memcached_server_instance_st was defined in 0.39. Built and tested against 0.31 and 0.49.
1 parent b0f5bff commit 468487d

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
6464
<file role='src' name='php_memcached.h'/>
6565
<file role='src' name='php_memcached_session.c'/>
6666
<file role='src' name='php_memcached_session.h'/>
67+
<file role='src' name='php_libmemcached_compat.h'/>
6768
<file role='src' name='g_fmt.c'/>
6869
<file role='src' name='g_fmt.h'/>
6970
<file role='src' name='fastlz/fastlz.c'/>

php_libmemcached_compat.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Here we define backwards compatibility for older
3+
* libmemcached API:s
4+
*
5+
* // Teddy Grenman <[email protected]>
6+
*/
7+
8+
#ifndef PHP_LIBMEMCACHED_COMPAT
9+
#define PHP_LIBMEMCACHED_COMPAT
10+
11+
#if !defined(LIBMEMCACHED_VERSION_HEX) || LIBMEMCACHED_VERSION_HEX < 0x00039000
12+
/* definition from libmemcached/types.h version 0.39+ */
13+
typedef const struct memcached_server_st *memcached_server_instance_st;
14+
#endif
15+
16+
#endif

php_memcached.c

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <ext/standard/basic_functions.h>
4646
#include <libmemcached/memcached.h>
4747

48+
#include "php_libmemcached_compat.h"
4849
#include "php_memcached.h"
4950
#include "g_fmt.h"
5051

php_memcached_session.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ps_module ps_mod_memcached = {
4747
/*
4848
* Stolen from libmemcached/common.h, because we need it and they don't expose it.
4949
*/
50-
static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary)
50+
static inline int memcached_validate_key_length(size_t key_length, bool binary)
5151
{
5252
if (key_length == 0)
5353
return MEMCACHED_BAD_KEY_PROVIDED;

0 commit comments

Comments
 (0)