当前位置:网站首页>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边栏推荐
- 1. error using XPath to locate tag
- h5 localStorage
- The best time to buy and sell stocks to get the maximum return
- Calculation of decoupling capacitance
- Teach you a few tricks: 30 "overbearing" warm words to coax girls, don't look regret!
- Oracle database self study notes
- SOC的多核启动流程详解
- JMeter performance testing - Basic Concepts
- 加密的JS代码,变量名能破解还原吗?
- [postgraduate entrance examination: planning group] clarify the relationship among memory, main memory, CPU, etc
猜你喜欢

Relationship extraction -- casrel

opencv学习笔记二
GHUnit: Unit Testing Objective-C for the iPhone

Crawler case 1: JS reversely obtains HD Wallpapers of minimalist Wallpapers

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

Analysis of internal circuit of operational amplifier

See which processes occupy specific ports and shut down

HEVC学习之码流分析
![[postgraduate entrance examination: planning group] clarify the relationship among memory, main memory, CPU, etc](/img/c2/d1432ab6021ee9da310103cc42beb3.jpg)
[postgraduate entrance examination: planning group] clarify the relationship among memory, main memory, CPU, etc

Introduction of laser drive circuit
随机推荐
软件工程-个人作业-提问回顾与个人总结
在 KubeSphere 部署 Wiki 系统 wiki.js 并启用中文全文检索
Assembly led on
MySQL practice: 3 Table operation
Necessary protection ring for weak current detection
鲸会务一站式智能会议系统帮助主办方实现数字化会议管理
Late 2021 plan
Cause analysis of serial communication overshoot and method of termination
Macro task, micro task, async, await principle of interview
Ora-12514: tns: the listener currently does not recognize the service requested in the connection descriptor
XXL job configuration alarm email notification
Idea update
GHUnit: Unit Testing Objective-C for the iPhone
Transformers loading Roberta to implement sequence annotation task
Database learning notes I
Batch execute SQL file
Learning signal integrity from scratch (SIPI) -- 3 challenges faced by Si and Si based design methods
Mapping '/var/mobile/Library/Caches/com. apple. keyboards/images/tmp. gcyBAl37' failed: 'Invalid argume
Oracle 19C local listener configuration error - no listener
Opencv learning notes II