当前位置:网站首页>VS2005 project call free() compiled with static libcurl library reported heap error
VS2005 project call free() compiled with static libcurl library reported heap error
2022-06-26 08:28:00 【Tonyfield】
curl There are many places to use strdup, but windows The next has been abandoned “strdup”, And ask for “_strdup” replace (
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/strdup-wcsdup?view=vs-2019).
That's what makes libcurl Static library call free() The cause of the abnormality in the process .
Actually libcurl The differences of memory allocation and release functions under different platforms have been considered , Library implementation malloc,calloc,strdup,free Such as function , What's actually called is easy.c As defined in Curl_cmalloc,Curl_ccalloc,Curl_cstrdup,Curl_cfree A function pointer , Initialization function global_init() Will define these function pointers .
/**
* curl_global_init() globally initializes curl given a bitwise set of the
* different features of what to initialize.
*/
static CURLcode global_init(long flags, bool memoryfuncs)
{
if(initialized++)
return CURLE_OK;
if(memoryfuncs) {
/* Setup the default memory functions here (again) */
Curl_cmalloc = (curl_malloc_callback)malloc;
Curl_cfree = (curl_free_callback)free;
Curl_crealloc = (curl_realloc_callback)realloc;
Curl_cstrdup = (curl_strdup_callback)system_strdup;
Curl_ccalloc = (curl_calloc_callback)calloc;
#if defined(WIN32) && defined(UNICODE)
Curl_cwcsdup = (curl_wcsdup_callback)_wcsdup;
#endif
}
if(!Curl_ssl_init()) {
DEBUGF(fprintf(stderr, "Error: Curl_ssl_init failed\n"));
goto fail;
}
#ifdef WIN32
if(Curl_win32_init(flags)) {
DEBUGF(fprintf(stderr, "Error: win32_init failed\n"));
goto fail;
}
#endif
among , Only Curl_cstrdup The default value of is special , It points to system_strdup . It can be seen that , Only in _WIN32_WCE Under defined conditions strdup Point to _strdup, Otherwise, call curlx_strdup or strdup , And because the config-win32.h In the definition of #define HAVE_STRDUP 1, So use VS Compilation will not use curlx_strdup, That's all strdup 了 .
#if defined(_WIN32_WCE)
#define system_strdup _strdup
#elif !defined(HAVE_STRDUP)
#define system_strdup curlx_strdup
#else
#define system_strdup strdup
#endifWe add here WIN32 Judge the condition , In this way visual studio Call down strdup Will point to the desired security function _strdup.
- #if defined(_WIN32_WCE)
+ #if defined(_WIN32_WCE) || defined(_WIN32) ||defined(WIN32)
#define system_strdup _strdup
#elif !defined(HAVE_STRDUP)
#define system_strdup curlx_strdup
#else
#define system_strdup strdup
#endif边栏推荐
- How to Use Instruments in Xcode
- Batch modify file name
- Opencv learning notes 3
- Torch model to tensorflow
- Reflection example of ads2020 simulation signal
- MySQL practice: 1 Common database commands
- How to Use Instruments in Xcode
- Oracle database self study notes
- Learn signal integrity from zero (SIPI) - (1)
- drf的相关知识
猜你喜欢

Esp8266wifi module tutorial: punctual atom atk-esp8266 for network communication, single chip microcomputer and computer, single chip microcomputer and mobile phone to send data

Uploading pictures with FileReader object

Diode voltage doubling circuit

What is Qi certification Qi certification process

Jupyter的安装

opencv学习笔记二

The difference between push-pull circuit drive and totem pole drive

Necessary protection ring for weak current detection

(2) Buzzer

Flume learning notes
随机推荐
Database learning notes I
Mapping '/var/mobile/Library/Caches/com. apple. keyboards/images/tmp. gcyBAl37' failed: 'Invalid argume
Assembly led on
Embedded Software Engineer (6-15k) written examination interview experience sharing (fresh graduates)
Swift code implements method calls
【Unity Mirror】NetworkTeam的使用
Interpretation of x-vlm multimodal model
MySQL practice: 1 Common database commands
STM32 project design: temperature, humidity and air quality alarm, sharing source code and PCB
STM32 project design: smart home system design based on stm32
在 KubeSphere 部署 Wiki 系统 wiki.js 并启用中文全文检索
Learning signal integrity from scratch (SIPI) -- 3 challenges faced by Si and Si based design methods
Golang JSON unsupported value: Nan processing
OpenCV Learning notes iii
Zlmediakit push pull flow test
Analysis of internal circuit of operational amplifier
Introduction of laser drive circuit
(vs2019 MFC connects to MySQL) make a simple login interface (detailed)
Opencv learning notes 3
X-VLM多模态模型解读