OCT 1.修正接口内存泄漏

This commit is contained in:
dongwenze 2023-03-06 16:34:07 +08:00
parent c303960261
commit 32fec2621b
1 changed files with 9 additions and 1 deletions

View File

@ -798,8 +798,11 @@ void iptvCacheCb(void *UNUSED(pArg)) {
// 新发现设备没有被上报过 // 新发现设备没有被上报过
if (!pTemp) { if (!pTemp) {
auto pCacheDev = (PIPTV_DEV_SET)malloc(sizeof(IPTV_DEV_SET)); auto pCacheDev = (PIPTV_DEV_SET)malloc(sizeof(IPTV_DEV_SET));
auto pRepDev = (PIPTV_DEV_SET)malloc(sizeof(IPTV_DEV_SET));
memcpy(pCacheDev, pDev, sizeof(IPTV_DEV_SET)); memcpy(pCacheDev, pDev, sizeof(IPTV_DEV_SET));
HASH_ADD_STR(report, iptvMAC, pCacheDev); memcpy(pRepDev, pDev, sizeof(IPTV_DEV_SET));
HASH_ADD_STR(report, iptvMAC, pRepDev);
isReport = true; isReport = true;
// 添加到缓存列表供后续查询 // 添加到缓存列表供后续查询
@ -836,6 +839,11 @@ void iptvCacheCb(void *UNUSED(pArg)) {
inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro); inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro);
} }
HASH_ITER(hh, report, pDev, pTmp) {
HASH_DEL(report, pDev);
free(pDev);
}
uv_sleep(10); uv_sleep(10);
} while (true); } while (true);
} }