summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/pr_new.rst
blob: 0fd9973419ab8a659f00ef46999f4d8cbfa08931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
PR_NEW
======

Allocates memory of a specified size from the heap.


Syntax
------

.. code::

   #include <prmem.h>

   _type * PR_NEW(_struct);


Parameter
~~~~~~~~~

``_struct``
   The name of a type.


Returns
~~~~~~~

An pointer to a buffer sized to contain the type ``_struct``, or if the
allocation attempt fails, ``NULL``. Call ``PR_GetError()`` to retrieve
the error returned by the libc function.


Description
-----------

This macro allocates memory whose size is ``sizeof(_struct)`` and
returns a pointer to that memory.