/***************************************************************************** * Copyright (C) 2004-2021 * ProbeStar Technical Systems, LLC * All Rights Reserved. Proprietary and Confidential. *============================================================================ *****************************************************************************/ /***************************************************************************** * includes *****************************************************************************/ #include #include "embtypes.h" #include "asn1uper.h" /***************************************************************************** * defines *****************************************************************************/ /***************************************************************************** * macros *****************************************************************************/ /***************************************************************************** * structs & typedefs *****************************************************************************/ /***************************************************************************** * global constants *****************************************************************************/ /***************************************************************************** * global variables *****************************************************************************/ /***************************************************************************** * static constants *****************************************************************************/ /***************************************************************************** * static variables *****************************************************************************/ /***************************************************************************** * static prototypes *****************************************************************************/ /***************************************************************************** * C functions *****************************************************************************/ void uper_init_stream(UPER_Stream *strm, uint8_t *ptr, uint max) { if (strm && ptr && max) { strm->buf = ptr; strm->ptr = ptr; strm->align = ASN1_UPER_ALIGNED; strm->bit = 0; strm->max = max; strm->consumed = 0; strm->error = 0; } } UPER_Stream *uper_alloc_stream(uint8_t *ptr, uint max) { UPER_Stream *uper = (UPER_Stream*)calloc(1, sizeof(UPER_Stream)); if (uper) { if (!ptr && max) { ptr = (uint8_t*)calloc(max/8+1,1); uper->alloc = 1; } uper_init_stream(uper, ptr, max); } return uper; } void uper_free_stream(UPER_Stream *uper) { if (uper) { if (uper->buf && uper->alloc) free(uper->buf); free(uper); } }