curl_easy_cleanup没有清除卷曲指针

时间:2015-07-10 10:04:37

标签: c++ c curl libcurl

当我执行 curl_easy_perform 时,我会像这样执行 curl_easy_cleanup

 <?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="rectangle">
            <solid android:color="#ffff7a00" />
        </shape>
    </item>

    <item
        android:bottom="2dp">
        <shape android:shape="rectangle">
            <solid android:color="#222222" />
        </shape>
    </item>
</layer-list>

我在调试器中注意到pEasy指针的地址及其说的0x2af0ad18但是在我执行 curl_easy_cleanup 之后它仍然是0x2af0ad18。

我必须在之后将其设置为nullptr吗? 我希望curl_easy_cleanup能为我重置这个???

1 个答案:

答案 0 :(得分:2)

http://curl.haxx.se/libcurl/c/curl_easy_cleanup.html

该函数采用指针,您希望它如何更改本地范围内某些值?

当您致电free(x)时,它不会将x设置为null它只会释放内存,这与curl_easy_cleanup正在做的事情是一样的。是否要将pEasy设置为nullptr之后取决于您,可能是一种良好的做法,但根据代码的布局以及pEasy是否即将超出范围而不必要。