CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
105 lines
2.3 KiB
C
105 lines
2.3 KiB
C
/*
|
|
** 2011-08-18
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
**
|
|
** Helper routines for memory allocation.
|
|
*/
|
|
#include "lsmInt.h"
|
|
|
|
/*
|
|
** The following routines are called internally by LSM sub-routines. In
|
|
** this case a valid environment pointer must be supplied.
|
|
*/
|
|
void *lsmMalloc(lsm_env *pEnv, size_t N){
|
|
assert( pEnv );
|
|
return pEnv->xMalloc(pEnv, N);
|
|
}
|
|
void lsmFree(lsm_env *pEnv, void *p){
|
|
assert( pEnv );
|
|
pEnv->xFree(pEnv, p);
|
|
}
|
|
void *lsmRealloc(lsm_env *pEnv, void *p, size_t N){
|
|
assert( pEnv );
|
|
return pEnv->xRealloc(pEnv, p, N);
|
|
}
|
|
|
|
/*
|
|
** Core memory allocation routines for LSM.
|
|
*/
|
|
void *lsm_malloc(lsm_env *pEnv, size_t N){
|
|
return lsmMalloc(pEnv ? pEnv : lsm_default_env(), N);
|
|
}
|
|
void lsm_free(lsm_env *pEnv, void *p){
|
|
lsmFree(pEnv ? pEnv : lsm_default_env(), p);
|
|
}
|
|
void *lsm_realloc(lsm_env *pEnv, void *p, size_t N){
|
|
return lsmRealloc(pEnv ? pEnv : lsm_default_env(), p, N);
|
|
}
|
|
|
|
void *lsmMallocZero(lsm_env *pEnv, size_t N){
|
|
void *pRet;
|
|
assert( pEnv );
|
|
pRet = lsmMalloc(pEnv, N);
|
|
if( pRet ) memset(pRet, 0, N);
|
|
return pRet;
|
|
}
|
|
|
|
void *lsmMallocRc(lsm_env *pEnv, size_t N, int *pRc){
|
|
void *pRet = 0;
|
|
if( *pRc==LSM_OK ){
|
|
pRet = lsmMalloc(pEnv, N);
|
|
if( pRet==0 ){
|
|
*pRc = LSM_NOMEM_BKPT;
|
|
}
|
|
}
|
|
return pRet;
|
|
}
|
|
|
|
void *lsmMallocZeroRc(lsm_env *pEnv, size_t N, int *pRc){
|
|
void *pRet = 0;
|
|
if( *pRc==LSM_OK ){
|
|
pRet = lsmMallocZero(pEnv, N);
|
|
if( pRet==0 ){
|
|
*pRc = LSM_NOMEM_BKPT;
|
|
}
|
|
}
|
|
return pRet;
|
|
}
|
|
|
|
void *lsmReallocOrFree(lsm_env *pEnv, void *p, size_t N){
|
|
void *pNew;
|
|
pNew = lsm_realloc(pEnv, p, N);
|
|
if( !pNew ) lsm_free(pEnv, p);
|
|
return pNew;
|
|
}
|
|
|
|
void *lsmReallocOrFreeRc(lsm_env *pEnv, void *p, size_t N, int *pRc){
|
|
void *pRet = 0;
|
|
if( *pRc ){
|
|
lsmFree(pEnv, p);
|
|
}else{
|
|
pRet = lsmReallocOrFree(pEnv, p, N);
|
|
if( !pRet ) *pRc = LSM_NOMEM_BKPT;
|
|
}
|
|
return pRet;
|
|
}
|
|
|
|
char *lsmMallocStrdup(lsm_env *pEnv, const char *zIn){
|
|
int nByte;
|
|
char *zRet;
|
|
nByte = strlen(zIn);
|
|
zRet = lsmMalloc(pEnv, nByte+1);
|
|
if( zRet ){
|
|
memcpy(zRet, zIn, nByte+1);
|
|
}
|
|
return zRet;
|
|
}
|