aboutsummaryrefslogtreecommitdiff
path: root/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c')
-rw-r--r--sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c44
1 files changed, 6 insertions, 38 deletions
diff --git a/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c b/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c
index d27e5461171a..dfbe6f635627 100644
--- a/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c
+++ b/sys/contrib/openzfs/module/zstd/lib/common/zstd_common.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0-only
/*
- * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under both the BSD-style license (found in the
@@ -14,8 +14,7 @@
/*-*************************************
* Dependencies
***************************************/
-#include <stdlib.h> /* malloc, calloc, free */
-#include <string.h> /* memset */
+#define ZSTD_DEPS_NEED_MALLOC
#include "error_private.h"
#include "zstd_internal.h"
@@ -31,10 +30,13 @@ const char* ZSTD_versionString(void) { return ZSTD_VERSION_STRING; }
/*-****************************************
* ZSTD Error Management
******************************************/
-
+#undef ZSTD_isError /* defined within zstd_internal.h */
/*! ZSTD_isError() :
* tells if a return value is an error code
* symbol is required for external callers */
+#if !defined(_STANDALONE)
+unsigned ZSTD_isError(size_t code) __asm__("zfs_ZSTD_isError");
+#endif
unsigned ZSTD_isError(size_t code) { return ERR_isError(code); }
/*! ZSTD_getErrorName() :
@@ -48,37 +50,3 @@ ZSTD_ErrorCode ZSTD_getErrorCode(size_t code) { return ERR_getErrorCode(code); }
/*! ZSTD_getErrorString() :
* provides error code string from enum */
const char* ZSTD_getErrorString(ZSTD_ErrorCode code) { return ERR_getErrorString(code); }
-
-
-
-/*=**************************************************************
-* Custom allocator
-****************************************************************/
-void* ZSTD_malloc(size_t size, ZSTD_customMem customMem)
-{
- if (customMem.customAlloc)
- return customMem.customAlloc(customMem.opaque, size);
- return malloc(size);
-}
-
-void* ZSTD_calloc(size_t size, ZSTD_customMem customMem)
-{
- if (customMem.customAlloc) {
- /* calloc implemented as malloc+memset;
- * not as efficient as calloc, but next best guess for custom malloc */
- void* const ptr = customMem.customAlloc(customMem.opaque, size);
- memset(ptr, 0, size);
- return ptr;
- }
- return calloc(1, size);
-}
-
-void ZSTD_free(void* ptr, ZSTD_customMem customMem)
-{
- if (ptr!=NULL) {
- if (customMem.customFree)
- customMem.customFree(customMem.opaque, ptr);
- else
- free(ptr);
- }
-}