---
name: "krb5_data_free"
section: "3"
platform: "linux"
package: "heimdal-dev"
version: "1.2.dfsg.1-2.1+lenny1"
release: "Debian 5.0 (Lenny)"
platforms: ["linux"]
url: "https://new.carta.tech/krb5_data_free"
---

# krb5\_data\_free(3)

operates on the Kerberos datatype krb5\_data

## NAME

**krb5\_data**, **krb5\_data\_zero**, **krb5\_data\_free**, **krb5\_free\_data\_contents**, **krb5\_free\_data**, **krb5\_data\_alloc**, **krb5\_data\_realloc**, **krb5\_data\_copy**, **krb5\_copy\_data**, **krb5\_data\_cmp** – operates on the Kerberos datatype krb5\_data

## LIBRARY

Kerberos 5 Library (libkrb5, -lkrb5)

## SYNOPSIS

**#include \<krb5.h\>**

struct krb5\_data;

*void*\

**krb5\_data\_zero**(*krb5\_data \*p*);

*void*\

**krb5\_data\_free**(*krb5\_data \*p*);

*void*\

**krb5\_free\_data\_contents**(*krb5\_context context*, *krb5\_data \*p*);

*void*\

**krb5\_free\_data**(*krb5\_context context*, *krb5\_data \*p*);

*krb5\_error\_code*\

**krb5\_data\_alloc**(*krb5\_data \*p*, *int len*);

*krb5\_error\_code*\

**krb5\_data\_realloc**(*krb5\_data \*p*, *int len*);

*krb5\_error\_code*\

**krb5\_data\_copy**(*krb5\_data \*p*, *const void \*data*, *size\_t len*);

*krb5\_error\_code*\

**krb5\_copy\_data**(*krb5\_context context*, *const krb5\_data \*indata*, *krb5\_data \*\*outdata*);

*krb5\_error\_code*\

**krb5\_data\_cmp**(*const krb5\_data \*data1*, *const krb5\_data \*data2*);

## DESCRIPTION

The krb5\_data structure holds a data element. The structure contains two public accessible elements *length* (the length of data) and *data* (the data itself). The structure must always be initiated and freed by the functions documented in this manual.

**krb5\_data\_zero**() resets the content of *p*.

**krb5\_data\_free**() free the data in *p* and reset the content of the structure with **krb5\_data\_zero**().

**krb5\_free\_data\_contents**() works the same way as *krb5\_data\_free*. The diffrence is that krb5\_free\_data\_contents is more portable (exists in MIT api).

**krb5\_free\_data**() frees the data in *p* and *p* itself.

**krb5\_data\_alloc**() allocates *len* bytes in *p*. Returns 0 or an error.

**krb5\_data\_realloc**() reallocates the length of *p* to the length in *len*. Returns 0 or an error.

**krb5\_data\_copy**() copies the *data* that have the length *len* into *p*. *p* is not freed so the calling function should make sure the *p* doesn't contain anything needs to be freed. Returns 0 or an error.

**krb5\_copy\_data**() copies the krb5\_data in *indata* to *outdata*. *outdata* is not freed so the calling function should make sure the *outdata* doesn't contain anything needs to be freed. *outdata* should be freed using **krb5\_free\_data**(). Returns 0 or an error.

**krb5\_data\_cmp**() will compare two data object and check if they are the same in a simular way as memcmp does it.  The return value can be used for sorting.

## SEE ALSO

[krb5(3)](/krb5/3.md), [krb5\_storage(3)](/krb5_storage/3.md), [kerberos(8)](/kerberos/8.md)
