NAME

XtMalloc, XtCalloc, XtRealloc, XtFree, XtNew, XtNewString - memory management functions

SYNTAX

char *XtMalloc(Cardinal _s_i_z_e); char *XtCalloc(Cardinal _n_u_m, Cardinal _s_i_z_e); char *XtRealloc(char *_p_t_r, Cardinal _n_u_m); void XtFree(char *_p_t_r); _t_y_p_e *XtNew(_t_y_p_e); String XtNewString(String _s_t_r_i_n_g);

ARGUMENTS

_n_u_m Specifies the number of bytes or array elements.
_p_t_r Specifies a pointer to the old storage or to the block of storage that is to be freed.
_s_i_z_e Specifies the size of an array element (in bytes) or the number of bytes
desired.
_s_t_r_i_n_g Specifies a previously declared string.
_t_y_p_e Specifies a previously declared data type.

DESCRIPTION

The _X_t_M_a_l_l_o_c functions returns a pointer to a block of storage of at least the specified size bytes. If there is insufficient memory to allocate the new block, _X_t_M_a_l_l_o_c calls _X_t_E_r_r_o_r_M_s_g.

The _X_t_C_a_l_l_o_c function allocates space for the specified number of array elements of the specified size and initializes the space to zero. If there is insufficient memory to allocate the new block, _X_t_C_a_l_l_o_c calls _X_t_E_r_r_o_r_M_s_g.

The _X_t_R_e_a_l_l_o_c function changes the size of a block of storage (possibly moving it). Then, it copies the old contents (or as much as will fit) into the new block and frees the old block. If there is insufficient memory to allocate the new block, _X_t_R_e_a_l_l_o_c calls _X_t_E_r_r_o_r_M_s_g. If ptr is NULL, _X_t_R_e_a_l_l_o_c allocates the new storage without copying the old contents; that is, it simply calls _X_t_M_a_l_l_o_c.

The _X_t_F_r_e_e function returns storage and allows it to be reused. If ptr is NULL, _X_t_F_r_e_e returns immediately.

_X_t_N_e_w returns a pointer to the allocated storage. If there is insufficient memory to allocate the new block, _X_t_N_e_w calls _X_t_E_r_r_o_r_M_s_g. _X_t_N_e_w is a convenience macro that calls _X_t_M_a_l_l_o_c with the following arguments specified:


((type *) XtMalloc((unsigned) sizeof(type))


_X_t_N_e_w_S_t_r_i_n_g returns a pointer to the allocated storage. If there is insufficient memory to allocate the new block, _X_t_N_e_w_S_t_r_i_n_g calls _X_t_E_r_r_o_r_M_s_g. _X_t_N_e_w_S_t_r_i_n_g is a convenience macro that calls _X_t_M_a_l_l_o_c with the following arguments specified:


(strcpy(XtMalloc((unsigned) strlen(str) + 1), str))


SEE ALSO


_X _T_o_o_l_k_i_t _I_n_t_r_i_n_s_i_c_s _- _C _L_a_n_g_u_a_g_e _I_n_t_e_r_f_a_c_e
_X_l_i_b _- _C _L_a_n_g_u_a_g_e _X _I_n_t_e_r_f_a_c_e