gpt4 book ai didi

c - 什么时候需要 curl_global_init() ?

转载 作者:太空狗 更新时间:2023-10-29 16:36:00 24 4
gpt4 key购买 nike

虽然它的文档说这个功能是必须的,但是我看到了两个例子,一个有,一个没有。

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

http://curl.haxx.se/libcurl/c/multi-app.html

这个功能有必要吗?

最佳答案

如果它被设计出来,那将是必要的。 documentation说:

This function must be called at least once within a program (a program is all the code that shares a memory space) before the program calls any other function in libcurl. The environment it sets up is constant for the life of the program and is the same for every program, so multiple calls have the same effect as one call.

但请注意,在 curl_easy_init 的文档中:

If you did not already call curl_global_init(3), curl_easy_init(3) does it automatically. This may be lethal in multi-threaded cases, since curl_global_init(3) is not thread-safe, and it may result in resource problems because there is no corresponding cleanup.

关于c - 什么时候需要 curl_global_init() ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6087886/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com