1. 程式人生 > >copy on write

copy on write

base span += str process pass processor copy empty

 1 yl::string CBaseAutopProcessor::AddAuthorizedInfo(const yl::string & strOriginalUrl,
 2         const yl::string & strUserName, const yl::string & strPassword)
 3 {
 4     yl::string strUrl = strOriginalUrl;//cow exist error
 5 
 6     if (strOriginalUrl.empty()
 7             || strUserName.empty())
8 { 9 return strUrl; 10 } 11 12 char * pBuf = (char *) strUrl.c_str(); 13 char * pTemp = NULL; 14 if ((pTemp = strstr(pBuf, "://")) != NULL) 15 { 16 *pTemp = \0; //cow will cause strUrl and strOriginalUrl change 17 pTemp += 3; 18 19 // 加入用戶名和密碼 20
char bufURL[512] = {0}; 21 sprintf(bufURL, "%s://%s:%s@%s", pBuf, strUserName.c_str(), strPassword.c_str(), pTemp); 22 strUrl = bufURL; 23 } 24 25 return strUrl; 26 }

copy on write