Skip to content

Commit

Permalink
Merge pull request #404 from beru/its_time_to_end_auto_array_ptr_in_f…
Browse files Browse the repository at this point in the history
…avour_of_std_unique_ptr

auto_array_ptr を廃止して std::unique_ptr に置き換え
  • Loading branch information
beru authored Sep 6, 2018
2 parents bcfe60b + c1a9fe4 commit 4aa227c
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 115 deletions.
2 changes: 0 additions & 2 deletions sakura/sakura.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,6 @@
<ClInclude Include="..\sakura_core\util\module.h" />
<ClInclude Include="..\sakura_core\util\ole_convert.h" />
<ClInclude Include="..\sakura_core\util\os.h" />
<ClInclude Include="..\sakura_core\util\other_util.h" />
<ClInclude Include="..\sakura_core\util\RegKey.h" />
<ClInclude Include="..\sakura_core\util\relation_tool.h" />
<ClInclude Include="..\sakura_core\util\shell.h" />
Expand Down Expand Up @@ -895,7 +894,6 @@
<ClCompile Include="..\sakura_core\util\module.cpp" />
<ClCompile Include="..\sakura_core\util\ole_convert.cpp" />
<ClCompile Include="..\sakura_core\util\os.cpp" />
<ClCompile Include="..\sakura_core\util\other_util.cpp" />
<ClCompile Include="..\sakura_core\util\relation_tool.cpp" />
<ClCompile Include="..\sakura_core\util\shell.cpp" />
<ClCompile Include="..\sakura_core\util\string_ex.cpp" />
Expand Down
6 changes: 0 additions & 6 deletions sakura/sakura.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,6 @@
<ClInclude Include="..\sakura_core\util\os.h">
<Filter>Cpp Source Files\util</Filter>
</ClInclude>
<ClInclude Include="..\sakura_core\util\other_util.h">
<Filter>Cpp Source Files\util</Filter>
</ClInclude>
<ClInclude Include="..\sakura_core\util\RegKey.h">
<Filter>Cpp Source Files\util</Filter>
</ClInclude>
Expand Down Expand Up @@ -1451,9 +1448,6 @@
<ClCompile Include="..\sakura_core\util\os.cpp">
<Filter>Cpp Source Files\util</Filter>
</ClCompile>
<ClCompile Include="..\sakura_core\util\other_util.cpp">
<Filter>Cpp Source Files\util</Filter>
</ClCompile>
<ClCompile Include="..\sakura_core\util\relation_tool.cpp">
<Filter>Cpp Source Files\util</Filter>
</ClCompile>
Expand Down
8 changes: 4 additions & 4 deletions sakura_core/CGrepAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
#include "io/CBinaryStream.h"
#include "util/window.h"
#include "util/module.h"
#include "util/other_util.h"
#include "debug/CRunningTimer.h"
#include <deque>
#include <memory>
#include "sakura_rc.h"

#define UICHECK_INTERVAL_MILLISEC 100 // UI確認の時間間隔
Expand Down Expand Up @@ -63,8 +63,8 @@ void CGrepAgent::OnAfterSave(const SSaveInfo& sSaveInfo)
void CGrepAgent::CreateFolders( const TCHAR* pszPath, std::vector<std::tstring>& vPaths )
{
const int nPathLen = auto_strlen( pszPath );
auto_array_ptr<TCHAR> szPath(new TCHAR[nPathLen + 1]);
auto_array_ptr<TCHAR> szTmp(new TCHAR[nPathLen + 1]);
auto szPath = std::make_unique<TCHAR[]>(nPathLen + 1);
auto szTmp = std::make_unique<TCHAR[]>(nPathLen + 1);
auto_strcpy( &szPath[0], pszPath );
TCHAR* token;
int nPathPos = 0;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ int CGrepAgent::DoGrepFile(
X / O : (D)Folder(Abs) -> (G)RelPath(File)
X / X : (H)FullPath
*/
auto_array_ptr<wchar_t> pszWork(new wchar_t[auto_strlen(pszFullPath) + auto_strlen(pszCodeName) + 10]);
auto pszWork = std::make_unique<wchar_t[]>(auto_strlen(pszFullPath) + auto_strlen(pszCodeName) + 10);
wchar_t* szWork0 = &pszWork[0];
if( sGrepOption.bGrepOutputBaseFolder || sGrepOption.bGrepSeparateFolder ){
if( !bOutputBaseFolder && sGrepOption.bGrepOutputBaseFolder ){
Expand Down
6 changes: 3 additions & 3 deletions sakura_core/CHokanMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
Please contact the copyright holders to use this code for other purpose.
*/
#include "StdAfx.h"
#include <memory>
#include "CHokanMgr.h"
#include "env/CShareData.h"
#include "view/CEditView.h"
#include "plugin/CJackManager.h"
#include "plugin/CComplementIfObj.h"
#include "util/input.h"
#include "util/os.h"
#include "util/other_util.h"
#include "sakura_rc.h"

WNDPROC gm_wpHokanListProc;
Expand Down Expand Up @@ -577,7 +577,7 @@ BOOL CHokanMgr::DoHokan( int nVKey )
return FALSE;
}
int nLabelLen = List_GetTextLen( hwndList, nItem );
auto_array_ptr<WCHAR> wszLabel( new WCHAR [nLabelLen + 1] );
auto wszLabel = std::make_unique<WCHAR[]>(nLabelLen + 1);
List_GetText( hwndList, nItem, &wszLabel[0] );

/* テキストを貼り付け */
Expand Down Expand Up @@ -688,7 +688,7 @@ void CHokanMgr::ShowTip()
if( LB_ERR == nItem ) return ;

int nLabelLen = List_GetTextLen( hwndCtrl, nItem );
auto_array_ptr<WCHAR> szLabel( new WCHAR [nLabelLen + 1] );
auto szLabel = std::make_unique<WCHAR[]>(nLabelLen + 1);
List_GetText( hwndCtrl, nItem, &szLabel[0] ); // 選択中の単語を取得

pcEditView = reinterpret_cast<CEditView*>(m_lParam);
Expand Down
1 change: 0 additions & 1 deletion sakura_core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ util/MessageBoxF.o \
util/module.o \
util/ole_convert.o \
util/os.o \
util/other_util.o \
util/relation_tool.o \
util/shell.o \
util/string_ex.o \
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/doc/CDocOutline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "StdAfx.h"
#include <string.h>
#include <memory>
#include "doc/CDocOutline.h"
#include "doc/CEditDoc.h"
#include "doc/logic/CDocLine.h"
Expand All @@ -27,7 +28,6 @@
#include "charset/charcode.h"
#include "io/CTextStream.h"
#include "extmodule/CBregexp.h"
#include "util/other_util.h"



Expand Down Expand Up @@ -217,7 +217,7 @@ int CDocOutline::ReadRuleFile( const TCHAR* pszFilename, SOneRule* pcOneRule, in
void CDocOutline::MakeFuncList_RuleFile( CFuncInfoArr* pcFuncInfoArr, std::tstring& sTitleOverride )
{
/* ルールファイルの内容をバッファに読み込む */
auto_array_ptr<SOneRule> test(new SOneRule[1024]); // 1024個許可。 2007.11.29 kobake スタック使いすぎなので、ヒープに確保するように修正。
auto test = std::make_unique<SOneRule[]>(1024); // 1024個許可。 2007.11.29 kobake スタック使いすぎなので、ヒープに確保するように修正。
bool bRegex;
std::wstring title;
int nCount = ReadRuleFile(m_pcDocRef->m_cDocType.GetDocumentAttribute().m_szOutlineRuleFilename, test.get(), 1024, bRegex, title );
Expand Down
2 changes: 1 addition & 1 deletion sakura_core/doc/CEditDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "StdAfx.h"
#include <stdlib.h>
#include <string.h> // Apr. 03, 2003 genta
#include <memory>
#include <OleCtl.h>
#include "doc/CEditDoc.h"
#include "doc/logic/CDocLine.h" /// 2002/2/3 aroka
Expand Down Expand Up @@ -72,7 +73,6 @@
#include "util/file.h"
#include "util/format.h"
#include "util/module.h"
#include "util/other_util.h"
#include "util/string_ex2.h"
#include "util/window.h"
#include "sakura_rc.h"
Expand Down
8 changes: 4 additions & 4 deletions sakura_core/macro/CWSHIfObj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
*/

#include "StdAfx.h"
#include <memory>
#include "macro/CWSHIfObj.h"
#include "macro/CSMacroMgr.h" // MacroFuncInfo
#include "Funccode_enum.h" // EFunctionCode::FA_FROMMACRO
#include "util/other_util.h" // auto_array_ptr


//コマンド・関数を準備する
Expand Down Expand Up @@ -116,7 +116,7 @@ HRESULT CWSHIfObj::MacroCommand(int IntID, DISPPARAMS *Arguments, VARIANT* Resul
VariantInit(&ret);

// 2011.3.18 syat 引数の順序を正しい順にする
auto_array_ptr<VARIANTARG> rgvargParam( new VARIANTARG[ArgCount] );
auto rgvargParam = std::make_unique<VARIANTARG[]>(ArgCount);
for(I = 0; I < ArgCount; I++){
::VariantInit(&rgvargParam[ArgCount - I - 1]);
::VariantCopy(&rgvargParam[ArgCount - I - 1], &Arguments->rgvarg[I]);
Expand All @@ -136,8 +136,8 @@ HRESULT CWSHIfObj::MacroCommand(int IntID, DISPPARAMS *Arguments, VARIANT* Resul
// 最低4つは確保
int argCountMin = t_max(4, ArgCount);
// Nov. 29, 2005 FILE 引数を文字列で取得する
auto_array_ptr<LPWSTR> StrArgs( new LPWSTR[argCountMin] );
auto_array_ptr<int> strLengths( new int[argCountMin] );
auto StrArgs = std::make_unique<LPWSTR[]>(argCountMin);
auto strLengths = std::make_unique<int[]>(argCountMin);
for(I = ArgCount; I < argCountMin; I++ ){
StrArgs[I] = NULL;
strLengths[I] = 0;
Expand Down
4 changes: 2 additions & 2 deletions sakura_core/typeprop/CImpExpManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

#include "StdAfx.h"
#include <memory>
#include "CImpExpManager.h"
#include "typeprop/CDlgTypeAscertain.h"

Expand All @@ -38,7 +39,6 @@
#include "plugin/CPlugin.h"
#include "view/CEditView.h"
#include "view/colors/CColorStrategy.h"
#include "util/other_util.h"

/*-----------------------------------------------------------------------
定数
Expand Down Expand Up @@ -616,7 +616,7 @@ bool CImpExpRegex::Import( const wstring& sFileName, wstring& sErrMsg )
}

RegexKeywordInfo regexKeyArr[MAX_REGEX_KEYWORD];
auto_array_ptr<wchar_t> szKeyWordList(new wchar_t [ MAX_REGEX_KEYWORDLISTLEN ]);
auto szKeyWordList = std::make_unique<wchar_t[]>(MAX_REGEX_KEYWORDLISTLEN);
wchar_t* pKeyword = &szKeyWordList[0];
int keywordPos = 0;
TCHAR buff[MAX_REGEX_KEYWORDLEN + 20];
Expand Down
22 changes: 11 additions & 11 deletions sakura_core/typeprop/CPropTypesRegex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
//@@@ 2001.11.17 add start MIK

#include "StdAfx.h"
#include <memory>
#include "CPropTypes.h"
#include "env/CShareData.h"
#include "CRegexKeyword.h"
#include "typeprop/CImpExpManager.h" // 2010/4/23 Uchi
#include "util/shell.h"
#include "util/other_util.h"
#include "view/colors/EColorIndexType.h"
#include "sakura_rc.h"
#include "sakura.hh"
Expand Down Expand Up @@ -186,7 +186,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(
case IDC_BUTTON_REGEX_INS: /* 挿入 */
{
//挿入するキー情報を取得する。
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
::DlgItem_GetText( hwndDlg, IDC_EDIT_REGEX, &szKeyWord[0], nKeyWordSize );
if( szKeyWord[0] == _T('\0') ) return FALSE;
Expand Down Expand Up @@ -231,7 +231,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_ADD: /* 追加 */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
//最後のキー番号を取得する。
nIndex = ListView_GetItemCount( hwndList );
//追加するキー情報を取得する。
Expand Down Expand Up @@ -270,7 +270,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_UPD: /* 更新 */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
//選択中のキーを探す。
nIndex = ListView_GetNextItem( hwndList, -1, LVNI_ALL | LVNI_SELECTED );
if( -1 == nIndex )
Expand Down Expand Up @@ -321,7 +321,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_TOP: /* 先頭 */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
//選択中のキーを探す。
nIndex = ListView_GetNextItem( hwndList, -1, LVNI_ALL | LVNI_SELECTED );
Expand Down Expand Up @@ -351,7 +351,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_LAST: /* 最終 */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
nIndex = ListView_GetNextItem( hwndList, -1, LVNI_ALL | LVNI_SELECTED );
if( -1 == nIndex ) return FALSE;
Expand Down Expand Up @@ -380,7 +380,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_UP: /* 上へ */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
nIndex = ListView_GetNextItem( hwndList, -1, LVNI_ALL | LVNI_SELECTED );
if( -1 == nIndex ) return FALSE;
Expand Down Expand Up @@ -411,7 +411,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(

case IDC_BUTTON_REGEX_DOWN: /* 下へ */
{
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
nIndex = ListView_GetNextItem( hwndList, -1, LVNI_ALL | LVNI_SELECTED );
if( -1 == nIndex ) return FALSE;
Expand Down Expand Up @@ -498,7 +498,7 @@ INT_PTR CPropTypesRegex::DispatchEvent(
}
if( nPrevIndex != nIndex ) //@@@ 2003.03.26 MIK
{ //更新時にListViewのSubItemを正しく取得できないので、その対策
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
szKeyWord[0] = _T('\0');
ListView_GetItemText(hwndList, nIndex, 0, &szKeyWord[0], nKeyWordSize);
ListView_GetItemText(hwndList, nIndex, 1, szColorIndex, _countof(szColorIndex));
Expand Down Expand Up @@ -622,7 +622,7 @@ int CPropTypesRegex::GetData( HWND hwndDlg )
HWND hwndList;
int nIndex, i, j;
const int szKeyWordSize = _countof(m_Types.m_RegexKeywordList) * 2 + 1;
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ szKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(szKeyWordSize);
TCHAR szColorIndex[256];

//使用する・使用しない
Expand Down Expand Up @@ -712,7 +712,7 @@ bool CPropTypesRegex::CheckKeywordList(HWND hwndDlg, const TCHAR* szNewKeyWord,
const int nKeyWordSize = MAX_REGEX_KEYWORDLEN;
HWND hwndList = GetDlgItem( hwndDlg, IDC_LIST_REGEX );
int nIndex = ListView_GetItemCount(hwndList);
auto_array_ptr<TCHAR> szKeyWord(new TCHAR [ nKeyWordSize ]);
auto szKeyWord = std::make_unique<TCHAR[]>(nKeyWordSize);
int nKeywordLen = auto_strlen(to_wchar(szNewKeyWord)) + 1;
for(int i = 0; i < nIndex; i++){
if( i != nUpdateItem ){
Expand Down
2 changes: 0 additions & 2 deletions sakura_core/util/other_util.cpp

This file was deleted.

77 changes: 0 additions & 77 deletions sakura_core/util/other_util.h

This file was deleted.

0 comments on commit 4aa227c

Please sign in to comment.