---
name: "rte_stack_free_count"
section: "3"
platform: "linux"
package: "dpdk-doc"
version: "24.11.4-0+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rte_stack.h"
---

# rte\_stack\_free\_count(3)

Part of [rte\_stack.h(3)](/rte_stack.h/3.md).

## NAME

rte\_stack.h

## SYNOPSIS

`#include <stdalign.h>`\
 `#include <rte_debug.h>`\
 `#include <rte_errno.h>`\
 `#include <rte_memzone.h>`\
 `#include <rte_spinlock.h>`\
 `#include 'rte_stack_std.h'`\
 `#include 'rte_stack_lf.h'`\

### Macros

\#define **RTE\_STACK\_NAMESIZE**\
 \#define **RTE\_STACK\_F\_LF**   0x0001\

### Functions

static **\_\_rte\_always\_inline** unsigned int **rte\_stack\_push** (struct rte\_stack \*s, void \*const \*obj\_table, unsigned int n)\
 static **\_\_rte\_always\_inline** unsigned int **rte\_stack\_pop** (struct rte\_stack \*s, void \*\*obj\_table, unsigned int n)\
 static **\_\_rte\_always\_inline** unsigned int **rte\_stack\_count** (struct rte\_stack \*s)\
 static **\_\_rte\_always\_inline** unsigned int **rte\_stack\_free\_count** (struct rte\_stack \*s)\
 struct rte\_stack \* **rte\_stack\_create** (const char \*name, unsigned int count, int socket\_id, uint32\_t flags)\
 void **rte\_stack\_free** (struct rte\_stack \*s)\
 struct rte\_stack \* **rte\_stack\_lookup** (const char \*name)\

## Detailed Description

RTE Stack.

librte\_stack provides an API for configuration and use of a bounded stack of pointers. Push and pop operations are MT-safe, allowing concurrent access, and the interface supports pushing and popping multiple pointers at a time.

Definition in file **rte\_stack.h**.

## Macro Definition Documentation

### #define RTE\_STACK\_NAMESIZE

**Value:**.PP

```
               (RTE_MEMZONE_NAMESIZE - \
               sizeof(RTE_STACK_MZ_PREFIX) + 1)
```

The maximum length of a stack name.

Definition at line **28** of file **rte\_stack.h**.

### #define RTE\_STACK\_F\_LF 0x0001

The stack uses lock-free push and pop functions. This flag is only supported on x86\_64 or arm64 platforms, currently.

Definition at line **89** of file **rte\_stack.h**.

## Function Documentation

### static \_\_rte\_always\_inline unsigned int rte\_stack\_push (struct rte\_stack \* s, void \*const \* obj\_table, unsigned int n)` [static]`

Push several objects on the stack (MT-safe).

**Parameters**

*s* A pointer to the stack structure. \
 *obj\_table* A pointer to a table of void \* pointers (objects). \
 *n* The number of objects to push on the stack from the obj\_table.

**Returns**

Actual number of objects pushed (either 0 or *n*).

Definition at line **111** of file **rte\_stack.h**.

### static \_\_rte\_always\_inline unsigned int rte\_stack\_pop (struct rte\_stack \* s, void \*\* obj\_table, unsigned int n)` [static]`

Pop several objects from the stack (MT-safe).

**Parameters**

*s* A pointer to the stack structure. \
 *obj\_table* A pointer to a table of void \* pointers (objects). \
 *n* The number of objects to pull from the stack.

**Returns**

Actual number of objects popped (either 0 or *n*).

Definition at line **135** of file **rte\_stack.h**.

### static \_\_rte\_always\_inline unsigned int rte\_stack\_count (struct rte\_stack \* s)` [static]`

Return the number of used entries in a stack.

**Parameters**

*s* A pointer to the stack structure.

**Returns**

The number of used entries in the stack.

Definition at line **155** of file **rte\_stack.h**.

### static \_\_rte\_always\_inline unsigned int rte\_stack\_free\_count (struct rte\_stack \* s)` [static]`

Return the number of free entries in a stack.

**Parameters**

*s* A pointer to the stack structure.

**Returns**

The number of free entries in the stack.

Definition at line **174** of file **rte\_stack.h**.

### struct rte\_stack \* rte\_stack\_create (const char \* name, unsigned int count, int socket\_id, uint32\_t flags)

Create a new stack named *name* in memory.

This function uses `memzone_reserve()` to allocate memory for a stack of size *count*. The behavior of the stack is controlled by the *flags*.

**Parameters**

*name* The name of the stack. \
 *count* The size of the stack. \
 *socket\_id* The *socket\_id* argument is the socket identifier in case of NUMA. The value can be *SOCKET\_ID\_ANY* if there is no NUMA constraint for the reserved zone. \
 *flags* An OR of the following:

- •

  RTE\_STACK\_F\_LF: If this flag is set, the stack uses lock-free variants of the push and pop functions. Otherwise, it achieves thread-safety using a lock.

**Returns**

On success, the pointer to the new allocated stack. NULL on error with rte\_errno set appropriately. Possible errno values include:

- •

  ENOSPC - the maximum number of memzones has already been allocated

- •

  EEXIST - a stack with the same name already exists

- •

  ENOMEM - insufficient memory to create the stack

- •

  ENAMETOOLONG - name size exceeds RTE\_STACK\_NAMESIZE

- •

  ENOTSUP - platform does not support given flags combination.

### void rte\_stack\_free (struct rte\_stack \* s)

Free all memory used by the stack.

**Parameters**

*s* Pointer to stack created with **rte\_stack\_create()**. If s is NULL, no operation is performed.

### struct rte\_stack \* rte\_stack\_lookup (const char \* name)

Lookup a stack by its name.

**Parameters**

*name* The name of the stack.

**Returns**

The pointer to the stack matching the name, or NULL if not found, with rte\_errno set appropriately. Possible rte\_errno values include:

- •

  ENOENT - Stack with name *name* not found.

- •

  EINVAL - *name* pointer is NULL.

## Author

Generated automatically by Doxygen for DPDK from the source code.
