---
name: "reallocf"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/reallocf"
---

# reallocf(3)

memory reallocation function

## NAME

**reallocf** – memory reallocation function

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

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

*void* *\**\

**reallocf**(*void \*ptr*, *size\_t size*);

## DESCRIPTION

The **reallocf**() function is identical to the **realloc**() function, except that it will free the passed pointer when the requested memory cannot be allocated. This is a FreeBSD specific API designed to ease the problems with traditional coding styles for **realloc**() causing memory leaks in libraries.

## RETURN VALUES

The **reallocf**() function returns a pointer, possibly identical to *ptr*, to the allocated memory if successful; otherwise a NULL pointer is returned, and *errno* is set to ENOMEM if the error was the result of an allocation failure. The **reallocf**() function deletes the original buffer when an error occurs.

## SEE ALSO

[realloc(3)](/realloc/3.md)

## HISTORY

The **reallocf**() function first appeared in FreeBSD 3.0.
