ASN1_item_new,
    ASN1_item_free — generic
    ASN.1 value constructor and destructor
#include
    <openssl/asn1.h>
ASN1_VALUE *
  
  ASN1_item_new(const ASN1_ITEM
    *it);
void
  
  ASN1_item_free(ASN1_VALUE
    *val_in, const ASN1_ITEM *it);
ASN1_item_new()
    allocates and initializes an empty ASN.1 value of the type described by the
    global static object it.
If the item type described by
    it is reference counted,
    ASN1_item_free()
    decrements the reference count of val_in. Otherwise,
    or if the reference count reaches 0,
    ASN1_item_free() frees val_in,
    assuming that it is of the type described by it. If
    the true type of val_in fails to match the specified
    it, buffer overflows and segmentation faults are
    likely to occur. It is not possible to recover the type of an
    ASN1_VALUE object by inspecting it; the type always
    needs to be remembered separately.
ASN1_VALUE is an incomplete type, and
    pointers to it always require casting to the correct complete type before
    they can be dereferenced. For all practical purposes, a pointer to
    ASN1_VALUE is equivalent to a
    void pointer.
Depending on it, there
    are more than 150 different types that
    ASN1_item_new()
    may return. Most of them are pointers to structures or pointers to arrays of
    structures, but there are a few exceptions, for example: If
    it is ASN1_NULL_it,
    ASN1_item_new() returns a specific invalid pointer
    representing the unique ASN1_NULL object. If
    it is LONG_it,
    ASN1_item_new() does not return a pointer at all,
    but a long value cast to ASN1_VALUE
    *.
The ASN1_item_new() function returns the
    new ASN1_VALUE object if successful; otherwise
    NULL is returned and an error code can be retrieved
    with
    ERR_get_error(3).
ASN1_item_new() and
    ASN1_item_free() first appeared in OpenSSL 0.9.7 and
    have been available since OpenBSD 3.2.
The ASN1_VALUE type compromises type safety
    and invites programming mistakes that will typically have severe
    consequences.