From ba2eae63a4d1a165c9d303737b9e14f1ea7f3ce7 Mon Sep 17 00:00:00 2001 From: GarenJian-Intel Date: Tue, 19 Apr 2022 12:49:11 +0800 Subject: [PATCH] QATAPP-26069:Use attribute destructor instead of atexit for exitFunc Change-Id: Id04161da743c1eda15f86a1c287aaf810c7891f5 Signed-off-by: Chengfei Zhu --- README.md | 2 +- src/qatzip.c | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6131960..d93884b 100644 --- a/README.md +++ b/README.md @@ -332,7 +332,7 @@ Known issues relating to the QATzip are described in this section. | Reference | QATAPP-26069 | | Description | If the users call qzFree after qzMemDestory, they may encounter free memory error "free(): invalid pointe" | | Implication | User use qzMalloc API to allocte continuous memory | -| Resolution | Ensure qzFree is invoked before qzMemDestory | +| Resolution | Ensure qzMemDestory is invoked after qzFree, now we use attribute destructor to invoke qzMemDestory| | Affected OS | Linux | ## Intended Audience diff --git a/src/qatzip.c b/src/qatzip.c index 807d5cb..0fd2f4f 100755 --- a/src/qatzip.c +++ b/src/qatzip.c @@ -418,6 +418,8 @@ static void stopQat(void) g_process.qat_available = QZ_NONE; } +static void exitFunc(void) __attribute__((destructor)); + static void exitFunc(void) { int i = 0; @@ -670,12 +672,6 @@ int qzInit(QzSession_T *sess, unsigned char sw_backup) clearDevices(qat_hw); free(qat_hw); - rc = atexit(exitFunc); - if (unlikely(QZ_OK != rc)) { - QZ_ERROR("Error in register exit hander rc = %d\n", rc); - BACKOUT(QZ_NOSW_NO_HW); - } - rc = g_process.qz_init_status = QZ_OK; done: