2 +--------------------------------------------------------------------+
3 | libmemcached - C/C++ Client Library for memcached |
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted under the terms of the BSD license. |
7 | You should have received a copy of the license in a bundled file |
8 | named LICENSE; in case you did not receive a copy you can review |
9 | the terms online at: https://opensource.org/licenses/BSD-3-Clause |
10 +--------------------------------------------------------------------+
11 | Copyright (c) 2006-2014 Brian Aker https://datadifferential.com/ |
12 | Copyright (c) 2020 Michael Wallner <mike@php.net> |
13 +--------------------------------------------------------------------+
16 #include "libmemcached/common.h"
20 struct memcached_array_st
{
26 memcached_array_st
*memcached_array_clone(Memcached
*memc
, const memcached_array_st
*original
) {
28 return memcached_strcpy(memc
, original
->c_str
, original
->size
);
34 memcached_array_st
*memcached_strcpy(Memcached
*memc
, const char *str
, size_t str_length
) {
39 memcached_array_st
*array
= (struct memcached_array_st
*) libmemcached_malloc(
40 memc
, sizeof(struct memcached_array_st
) + str_length
+ 1);
44 array
->size
= str_length
; // We don't count the NULL ending
45 memcpy(array
->c_str
, str
, str_length
);
46 array
->c_str
[str_length
] = 0;
52 bool memcached_array_is_null(memcached_array_st
*array
) {
60 memcached_string_t
memcached_array_to_string(memcached_array_st
*array
) {
64 memcached_string_t tmp
;
65 tmp
.c_str
= array
->c_str
;
66 tmp
.size
= array
->size
;
71 void memcached_array_free(memcached_array_st
*array
) {
73 WATCHPOINT_ASSERT(array
->root
);
74 libmemcached_free(array
->root
, array
);
78 size_t memcached_array_size(memcached_array_st
*array
) {
86 const char *memcached_array_string(memcached_array_st
*array
) {