Skip to content

Commit

Permalink
QATAPP-26069:Use attribute destructor instead of atexit for exitFunc
Browse files Browse the repository at this point in the history
Change-Id: Id04161da743c1eda15f86a1c287aaf810c7891f5
Signed-off-by: Chengfei Zhu <chengfei.zhu@intel.com>
  • Loading branch information
GarenJian-Intel authored and cfzhu committed Apr 28, 2022
1 parent 14d9bf3 commit ba2eae6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions src/qatzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ba2eae6

Please sign in to comment.