---
name: "Memcached::libmemcached::memcached_create"
section: "3pm"
platform: "linux"
package: "libmemcached-libmemcached-perl"
version: "1.001801+dfsg-5+b2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Memcached::libmemcached::memcached_create"
---

# Memcached::libmemcached::memcached\_create(3pm)

## NAME

memcached\_create, memcached\_free, memcached\_clone, memcached\_servers\_reset- Create a memcached\_st structure

## LIBRARY

C Client Library for memcached (libmemcached, -lmemcached)

## SYNOPSIS

```
  #include <memcached.h>
  memcached_st *memcached_create (memcached_st *ptr);
  void memcached_free (memcached_st *ptr);
  memcached_st *memcached_clone (memcached_st *destination, memcached_st *source);
  void memcached_servers_reset(memcached_st);
```

## DESCRIPTION

**memcached\_create()** is used to create a `"memcached_st"` structure that will then be used by other [**libmemcached**(3)](/libmemcached/3.md) functions to communicate with the server. You should either pass a statically declared `"memcached_st"` to **memcached\_create()** or a NULL. If a NULL passed in then a structure is allocated for you.

**memcached\_clone()** is similar to [**memcached\_create**(3)](/memcached_create/3.md) but it copies the defaults and list of servers from the source `"memcached_st"`. If you pass a null as the argument for the source to clone, it is the same as a call to **memcached\_create()**. If the destination argument is NULL a `"memcached_st"` will be allocated for you.

**memcached\_servers\_reset()** allows you to zero out the list of servers that the memcached\_st has.

To clean up memory associated with a `"memcached_st"` structure you should pass it to **memcached\_free()** when you are finished using it. **memcached\_free()** is the only way to make sure all memory is deallocated when you finish using the structure.

You may wish to avoid using [**memcached\_create**(3)](/memcached_create/3.md) or [**memcached\_clone**(3)](/memcached_clone/3.md) with a stack based allocation. The most common issues related to ABI safety involve heap allocated structures.

## RETURN

**memcached\_create()** returns a pointer to the memcached\_st that was created (or initialized). On an allocation failure, it returns NULL.

**memcached\_clone()** returns a pointer to the memcached\_st that was created (or initialized). On an allocation failure, it returns NULL.

## HOME

To find out more information please check: \<https://launchpad.net/libmemcached\>

## AUTHOR

Brian Aker, \<brian@tangent.org\>

## SEE ALSO

[**memcached**(1)](/memcached/1.md) [**libmemcached**(3)](/libmemcached/3.md) [**memcached\_strerror**(3)](/memcached_strerror/3.md)
