/* rv_decode_destroy() * Deletes decoder and backend instance, followed by frontend. */ void rv_decode_destroy(rv_decode* pFrontEnd) { rm_free_func_ptr fpFree; void* pUserMem; if (pFrontEnd && pFrontEnd->fpFree) { /* Save a pointer to fpFree and pUserMem */ fpFree = pFrontEnd->fpFree; pUserMem = pFrontEnd->pUserMem; if (pFrontEnd->pDecode) { if (pFrontEnd->pDecode->fpFree && pFrontEnd->pDecodeState) { /* Free the decoder instance */ pFrontEnd->pDecode->fpFree(pFrontEnd->pDecodeState); pFrontEnd->pDecodeState = HXNULL; } /* Free the backend interface */ fpFree(pUserMem, pFrontEnd->pDecode); } /* Free the rv_decode struct memory */ fpFree(pUserMem, pFrontEnd); } }
void rm_parser_destroy(rm_parser** ppParser) { if (ppParser) { /* Get the internal parser struct */ rm_parser_internal* pInt = (rm_parser_internal*) *ppParser; if (pInt && pInt->fpFree) { /* Save a pointer to fpFree and pUserMem */ rm_free_func_ptr fpFree = pInt->fpFree; void* pUserMem = pInt->pUserMem; /* Clean up the content header */ rm_parseri_cleanup_content_hdr(pInt); /* Clean up the media props headers */ rm_parseri_cleanup_all_media_props_hdrs(pInt); /* Clean up all logical stream headers */ rm_parseri_cleanup_all_logical_stream_hdrs(pInt); /* Clean up the logical fileinfo header */ rm_parseri_cleanup_logical_fileinfo_hdr(pInt); //rm_parseri_cleanup_logical_stream_hdr(pInt, pInt->pLogicalFileInfo); /* Clean up the read buffer */ rm_parseri_cleanup_read_buffer(pInt); /* Free the stream num map */ rm_parseri_cleanup_stream_num_map(pInt); /* Clean up the stream info array */ rm_parseri_cleanup_stream_info_array(pInt); /* Clean up the stream header array */ rm_parseri_cleanup_all_stream_headers(pInt); /* Clean up the data header */ rm_parseri_cleanup_all_data_headers(pInt); /* Null everything out */ memset(pInt, 0, sizeof(rm_parser_internal)); /* Free the rm_parser_internal struct memory */ fpFree(pUserMem, pInt); /* NULL out the pointer */ *ppParser = HXNULL; } } }
rv_decode* rv_decode_create2(void* pUserError, rm_error_func_ptr fpError, void* pUserMem, rm_malloc_func_ptr fpMalloc, rm_free_func_ptr fpFree) { rv_decode* pRet = (rv_decode*)HXNULL; if (fpMalloc && fpFree) { pRet = (rv_decode*) fpMalloc(pUserMem, sizeof(rv_decode)); if (pRet) { /* Zero out the struct */ memset((void*) pRet, 0, sizeof(rv_decode)); /* Assign the error function */ pRet->fpError = fpError; pRet->pUserError = pUserError; /* Assign the memory functions */ pRet->fpMalloc = fpMalloc; pRet->fpFree = fpFree; pRet->pUserMem = pUserMem; /* Allocate the backend interface struct */ pRet->pDecode = (rv_backend*) fpMalloc(pUserMem, sizeof(rv_backend)); if (pRet->pDecode == HXNULL) { fpFree(pUserMem, pRet); pRet = (rv_decode *)HXNULL; } } } return pRet; }
BOOLEAN RTDevice::Free( void *Memory ) { if( fpFree ) return fpFree( Memory ); //If this is not supported we can do it manually if( LocalFree( Memory ) == NULL ) return TRUE; return FALSE; }