GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
xt_realloc(3) FreeBSD Library Functions Manual xt_realloc(3)

#include <xtend/mem.h>
-lxtend

void    *xt_realloc(void *array, size_t nelem, size_t size)

array:  Address of the previously allocated array
nelem:  Number of objects to allocate
size:   Size of a single object

xt_realloc() is a simple wrapper around realloc(3) that requires three arguments representing the original array, the new number of objects to allocate and the size of an element. This prevents the very common mistake with realloc(3) of forgetting to multiply by the size of an element. Specifying the size using sizeof(*variable) has the advantage of being type-independent. I.e. if you change the type of the variable, this code need not be updated.

Address of the newly allocated array, or NULL if allocation failed

#define     MAX_WIDGETS 1000
widget_t    *widgets;
widgets = xt_malloc(MAX_WIDGETS, sizeof(*widgets));
widgets = xt_realloc(widgets, new_widget_count, sizeof(*widgets));

realloc(3)


Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.