public static ZSTD_DDict_s *ZSTD_createDDict_advanced(void *dict, nuint dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType, ZSTD_customMem customMem) { if (((customMem.customAlloc == null ? 1 : 0) ^ (customMem.customFree == null ? 1 : 0)) != 0) { return((ZSTD_DDict_s *)null); } { ZSTD_DDict_s *ddict = (ZSTD_DDict_s *)(ZSTD_customMalloc((nuint)(sizeof(ZSTD_DDict_s)), customMem)); if (ddict == null) { return((ZSTD_DDict_s *)null); } ddict->cMem = customMem; { nuint initResult = ZSTD_initDDict_internal(ddict, dict, dictSize, dictLoadMethod, dictContentType); if ((ERR_isError(initResult)) != 0) { ZSTD_freeDDict(ddict); return((ZSTD_DDict_s *)null); } } return(ddict); } }
private static void ZSTD_cwksp_free(ZSTD_cwksp *ws, ZSTD_customMem customMem) { void *ptr = ws->workspace; memset((void *)(ws), (0), ((nuint)(sizeof(ZSTD_cwksp)))); ZSTD_customFree(ptr, customMem); }
public static void *ZSTD_customCalloc(nuint size, ZSTD_customMem customMem) { if (customMem.customAlloc != null) { throw new NotImplementedException("customMem is not implemented"); } return(calloc((1), (size))); }
/*! ZSTD_createDDict_byReference() : * Create a digested dictionary, to start decompression without startup delay. * Dictionary content is simply referenced, it will be accessed during decompression. * Warning : dictBuffer must outlive DDict (DDict must be freed before dictBuffer) */ public static ZSTD_DDict_s *ZSTD_createDDict_byReference(void *dictBuffer, nuint dictSize) { ZSTD_customMem allocator = new ZSTD_customMem { customAlloc = null, customFree = null, opaque = null, }; return(ZSTD_createDDict_advanced(dictBuffer, dictSize, ZSTD_dictLoadMethod_e.ZSTD_dlm_byRef, ZSTD_dictContentType_e.ZSTD_dct_auto, allocator)); }
private static nuint ZSTD_cwksp_create(ZSTD_cwksp *ws, nuint size, ZSTD_customMem customMem) { void *workspace = ZSTD_customMalloc(size, customMem); if (workspace == null) { return(unchecked ((nuint)(-(int)ZSTD_ErrorCode.ZSTD_error_memory_allocation))); } ZSTD_cwksp_init(ws, workspace, size, ZSTD_cwksp_static_alloc_e.ZSTD_cwksp_dynamic_alloc); return(0); }
public static void ZSTD_customFree(void *ptr, ZSTD_customMem customMem) { if (ptr != null) { if (customMem.customFree != null) { throw new NotImplementedException("customMem is not implemented"); } else { free((ptr)); } } }
/*! ZSTD_freeDDict() : * Function frees memory allocated with ZSTD_createDDict() */ public static nuint ZSTD_freeDDict(ZSTD_DDict_s *ddict) { if (ddict == null) { return(0); } { ZSTD_customMem cMem = ddict->cMem; ZSTD_customFree(ddict->dictBuffer, cMem); ZSTD_customFree((void *)ddict, cMem); return(0); } }