Header Ads Widget

[MAN] reallocf

Content-type: text/html; charset=UTF-8 Man page of REALLOCF

REALLOCF

Section: Misc. Reference Manual Pages (3bsd)
Index Return to Main Contents

BSD mandoc
 

NAME

reallocf - general purpose memory allocation functions  

LIBRARY

Lb libbsd  

SYNOPSIS

In stdlib.h (See libbsd(7) for include usage.) Ft void * Fn reallocf void *ptr size_t size  

DESCRIPTION

The Fn reallocf function changes the size of the previously allocated memory referenced by Fa ptr to Fa size bytes. The contents of the memory are unchanged up to the lesser of the new and old sizes. If the new size is larger, the contents of the newly allocated portion of the memory are undefined. Upon success, the memory referenced by Fa ptr is freed and a pointer to the newly allocated memory is returned. Note that Fn reallocf may move the memory allocation, resulting in a different return value than Fa ptr . If Fa ptr is NULL the Fn reallocf function behaves identically to Fn malloc for the specified size. Upon failure, when the requested memory cannot be allocated, the passed pointer is freed to ease the problems with traditional coding styles for Fn reallocf causing memory leaks in libraries.  

RETURN VALUES

The Fn reallocf function returns a pointer, possibly identical to Fa ptr , to the allocated memory if successful; otherwise a NULL pointer is returned, and errno is set to Er ENOMEM if the error was the result of an allocation failure. The buffer is deallocated in this case.  

SEE ALSO

brk(2), mmap(2), alloca(3), calloc(3), free(3), malloc(3), posix_memalign3, realloc(3),  

HISTORY

The Fn reallocf function first appeared in Fx 3.0 .


 

Index

NAME
LIBRARY
SYNOPSIS
DESCRIPTION
RETURN VALUES
SEE ALSO
HISTORY

This document was created by man2html, using the manual pages.
Time: 04:45:51 GMT, September 16, 2022

댓글 쓰기

0 댓글