Change BObjectList to take "owning" as a template parameter and adjust all consumers.
Since BObjectList is a template class, this only breaks ABI where BObjectList was exposed in public methods, and even then it's only a name mangling break and we should be able to add compatibility methods if necessary. (The old "bool owning" member variable is left intact for ABI compatibility, for the moment, though it's otherwise unused now.) Tracker's PoseList is the only remaining type that has a "bool owning" switch in the constructor rather than template parameters. This should significantly improve the output of static code analysis tools that previously detected list operations as causing use-after-frees and double-frees, as well as make code maintenance easier by making it easier to determine what list owns (or does not own) an object. It should also be a minor performance optimization, since the branches for calls to delete/free should now be optimized out altogether. Still boots to desktop and Tracker, Deskbar, Debugger all tested and verified as working. Change-Id: If2a24a6f0d22e7a506ef554fcfdd328907279ed4 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8915 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
007126ed6f
commit
cbfbbf6d4d
@@ -98,10 +98,10 @@ struct HyperTextView::ActionInfo {
|
||||
|
||||
|
||||
class HyperTextView::ActionInfoList
|
||||
: public BObjectList<HyperTextView::ActionInfo> {
|
||||
: public BObjectList<HyperTextView::ActionInfo, true> {
|
||||
public:
|
||||
ActionInfoList(int32 itemsPerBlock = 20, bool owning = false)
|
||||
: BObjectList<HyperTextView::ActionInfo>(itemsPerBlock, owning)
|
||||
ActionInfoList(int32 itemsPerBlock = 20)
|
||||
: BObjectList<HyperTextView::ActionInfo, true>(itemsPerBlock)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
HyperTextView::HyperTextView(const char* name, uint32 flags)
|
||||
:
|
||||
BTextView(name, flags),
|
||||
fActionInfos(new ActionInfoList(100, true)),
|
||||
fActionInfos(new ActionInfoList(100)),
|
||||
fLastActionInfo(NULL)
|
||||
{
|
||||
}
|
||||
@@ -120,7 +120,7 @@ HyperTextView::HyperTextView(BRect frame, const char* name, BRect textRect,
|
||||
uint32 resizeMask, uint32 flags)
|
||||
:
|
||||
BTextView(frame, name, textRect, resizeMask, flags),
|
||||
fActionInfos(new ActionInfoList(100, true)),
|
||||
fActionInfos(new ActionInfoList(100)),
|
||||
fLastActionInfo(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ BlockListItem::BlockListItem(const char* label, uint32 blockIndex)
|
||||
|
||||
UnicodeBlockView::UnicodeBlockView(const char* name)
|
||||
: BListView(name),
|
||||
fBlocks(kNumUnicodeBlocks, true),
|
||||
fBlocks(kNumUnicodeBlocks),
|
||||
fShowPrivateBlocks(false),
|
||||
fShowContainedBlocksOnly(false)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
void _CreateBlocks();
|
||||
|
||||
private:
|
||||
BObjectList<BlockListItem> fBlocks;
|
||||
BObjectList<BlockListItem, true> fBlocks;
|
||||
BString fFilter;
|
||||
bool fShowPrivateBlocks;
|
||||
bool fShowContainedBlocksOnly;
|
||||
|
||||
@@ -109,7 +109,7 @@ AbstractTable::AbstractTable(const char* name, uint32 flags,
|
||||
border_style borderStyle, bool showHorizontalScrollbar)
|
||||
:
|
||||
BColumnListView(name, flags, borderStyle, showHorizontalScrollbar),
|
||||
fColumns(20, false)
|
||||
fColumns(20)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ public:
|
||||
int32 IndexOf(TreeTableNode* child);
|
||||
|
||||
private:
|
||||
typedef BObjectList<TreeTableNode> NodeList;
|
||||
typedef BObjectList<TreeTableNode, true> NodeList;
|
||||
|
||||
private:
|
||||
TreeTableNode* fParent;
|
||||
@@ -532,7 +532,7 @@ bool
|
||||
TreeTableNode::AddChild(TreeTableNode* child, int32 index)
|
||||
{
|
||||
if (fChildren == NULL) {
|
||||
fChildren = new(std::nothrow) NodeList(10, true);
|
||||
fChildren = new(std::nothrow) NodeList(10);
|
||||
if (fChildren == NULL)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ DebuggerSettingsManager::DebuggerSettingsManager()
|
||||
:
|
||||
SettingsManager(),
|
||||
fLock("settings manager"),
|
||||
fRecentTeamSettings(kMaxRecentTeamSettings, true),
|
||||
fRecentTeamSettings(kMaxRecentTeamSettings),
|
||||
fUiSettingsFactory(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
virtual status_t SaveTeamSettings(const TeamSettings& settings);
|
||||
|
||||
private:
|
||||
typedef BObjectList<TeamSettings> TeamSettingsList;
|
||||
typedef BObjectList<TeamSettings, true> TeamSettingsList;
|
||||
|
||||
private:
|
||||
void _Unset();
|
||||
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
CommandLineUserInterface::CommandLineUserInterface()
|
||||
:
|
||||
fContext(new CliContext()),
|
||||
fCommands(20, true),
|
||||
fCommands(20),
|
||||
fShowSemaphore(-1),
|
||||
fShown(false),
|
||||
fTerminating(false)
|
||||
|
||||
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
private:
|
||||
struct CommandEntry;
|
||||
typedef BObjectList<CommandEntry> CommandList;
|
||||
typedef BObjectList<CommandEntry, true> CommandList;
|
||||
|
||||
struct HelpCommand;
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ GraphicalUserInterface::GraphicalUserInterface()
|
||||
fTeamWindowMessenger(NULL),
|
||||
fFilePanelHandler(NULL),
|
||||
fFilePanel(NULL),
|
||||
fDefaultActions(10, true)
|
||||
fDefaultActions(10)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
BString fKey;
|
||||
int fDecision;
|
||||
};
|
||||
BObjectList<DefaultAction> fDefaultActions;
|
||||
BObjectList<DefaultAction, true> fDefaultActions;
|
||||
};
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@
|
||||
ConnectionConfigHandlerRoster::ConnectionConfigHandlerRoster()
|
||||
:
|
||||
fLock("config handler roster lock"),
|
||||
fConfigHandlers(10, true)
|
||||
fConfigHandlers(10)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ public:
|
||||
ConnectionConfigView*& _view) const;
|
||||
|
||||
private:
|
||||
typedef BObjectList<ConnectionConfigHandler> HandlerList;
|
||||
typedef BObjectList<ConnectionConfigHandler, true> HandlerList;
|
||||
|
||||
private:
|
||||
bool _GetHandler(const BString& name,
|
||||
|
||||
@@ -174,7 +174,7 @@ ConsoleOutputView::SaveSettings(BMessage& settings)
|
||||
void
|
||||
ConsoleOutputView::_Init()
|
||||
{
|
||||
fPendingOutput = new OutputInfoList(10, true);
|
||||
fPendingOutput = new OutputInfoList(10);
|
||||
|
||||
fWorkToDoSem = create_sem(0, "output_work_available");
|
||||
if (fWorkToDoSem < 0)
|
||||
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
|
||||
private:
|
||||
struct OutputInfo;
|
||||
typedef BObjectList<OutputInfo> OutputInfoList;
|
||||
typedef BObjectList<OutputInfo, true> OutputInfoList;
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
|
||||
@@ -154,7 +154,7 @@ public:
|
||||
|
||||
template<typename MarkerType> struct MarkerByLinePredicate;
|
||||
|
||||
typedef BObjectList<Marker> MarkerList;
|
||||
typedef BObjectList<Marker> MarkerList;
|
||||
typedef BObjectList<BreakpointMarker> BreakpointMarkerList;
|
||||
|
||||
void GetMarkers(uint32 minLine, uint32 maxLine,
|
||||
@@ -190,8 +190,8 @@ private:
|
||||
SourceCode* fSourceCode;
|
||||
StackTrace* fStackTrace;
|
||||
StackFrame* fStackFrame;
|
||||
MarkerList fIPMarkers;
|
||||
BreakpointMarkerList fBreakpointMarkers;
|
||||
BObjectList<Marker, true> fIPMarkers;
|
||||
BObjectList<BreakpointMarker, true> fBreakpointMarkers;
|
||||
bool fIPMarkersValid;
|
||||
bool fBreakpointMarkersValid;
|
||||
|
||||
@@ -626,8 +626,8 @@ SourceView::MarkerManager::MarkerManager(SourceView* sourceView, Team* team,
|
||||
fListener(listener),
|
||||
fStackTrace(NULL),
|
||||
fStackFrame(NULL),
|
||||
fIPMarkers(10, true),
|
||||
fBreakpointMarkers(20, true),
|
||||
fIPMarkers(10),
|
||||
fBreakpointMarkers(20),
|
||||
fIPMarkersValid(false),
|
||||
fBreakpointMarkersValid(false)
|
||||
{
|
||||
|
||||
@@ -122,7 +122,7 @@ struct VariablesView::ExpressionInfoEntry : FunctionKey, ExpressionInfoList {
|
||||
ExpressionInfoEntry(FunctionID* function)
|
||||
:
|
||||
FunctionKey(function),
|
||||
ExpressionInfoList(10, false)
|
||||
ExpressionInfoList(10)
|
||||
{
|
||||
function->AcquireReference();
|
||||
}
|
||||
@@ -1792,7 +1792,7 @@ VariablesView::VariablesView(Listener* listener)
|
||||
fPreviousViewState(NULL),
|
||||
fViewStateHistory(NULL),
|
||||
fExpressions(NULL),
|
||||
fExpressionChildren(10, false),
|
||||
fExpressionChildren(10),
|
||||
fTableCellContextMenuTracker(NULL),
|
||||
fPendingTypecastInfo(NULL),
|
||||
fTemporaryExpression(NULL),
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
ValueHandlerRoster::ValueHandlerRoster()
|
||||
:
|
||||
fLock("value handler roster"),
|
||||
fValueHandlers(20, false)
|
||||
fValueHandlers(20)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ ValidationFailure::Archive(BMessage* into, bool deep) const
|
||||
|
||||
ValidationFailures::ValidationFailures(BMessage* from)
|
||||
:
|
||||
fItems(20, true)
|
||||
fItems(20)
|
||||
{
|
||||
_AddFromMessage(from);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ ValidationFailures::ValidationFailures(BMessage* from)
|
||||
|
||||
ValidationFailures::ValidationFailures()
|
||||
:
|
||||
fItems(20, true)
|
||||
fItems(20)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
ValidationFailure* _GetOrCreateFailure(const BString& property);
|
||||
|
||||
private:
|
||||
BObjectList<ValidationFailure>
|
||||
BObjectList<ValidationFailure, true>
|
||||
fItems;
|
||||
};
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class PeopleChoiceModel : public BAutoCompleter::ChoiceModel {
|
||||
public:
|
||||
PeopleChoiceModel()
|
||||
:
|
||||
fChoices(5, true)
|
||||
fChoices(5)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
BObjectList<BAutoCompleter::Choice> fChoices;
|
||||
BObjectList<BAutoCompleter::Choice, true> fChoices;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ Person::IsInGroup(const char* group) const
|
||||
PersonList::PersonList(QueryList& query)
|
||||
:
|
||||
fQueryList(query),
|
||||
fPersons(10, true)
|
||||
fPersons(10)
|
||||
{
|
||||
fQueryList.AddListener(this);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
typedef std::map<node_ref, Person*> PersonMap;
|
||||
|
||||
QueryList& fQueryList;
|
||||
BObjectList<Person> fPersons;
|
||||
BObjectList<Person, true> fPersons;
|
||||
PersonMap fPersonMap;
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ QueryListener::~QueryListener()
|
||||
QueryList::QueryList()
|
||||
:
|
||||
fQuit(false),
|
||||
fListeners(5, true)
|
||||
fListeners(5)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ private:
|
||||
QueryVector fQueries;
|
||||
QueryVector fQueryQueue;
|
||||
ThreadVector fFetchThreads;
|
||||
BObjectList<QueryListener> fListeners;
|
||||
BObjectList<QueryListener, true> fListeners;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -471,7 +471,7 @@ PlaylistWindow::_UpdateTotalDuration(bigtime_t duration)
|
||||
PlaylistWindow::DurationListener::DurationListener(PlaylistWindow& parent)
|
||||
:
|
||||
PlaylistObserver(this),
|
||||
fKnown(20, true),
|
||||
fKnown(20),
|
||||
fTotalDuration(0),
|
||||
fParent(parent)
|
||||
{
|
||||
|
||||
@@ -70,7 +70,7 @@ private:
|
||||
int32 index);
|
||||
void _HandleItemRemoved(int32 index);
|
||||
|
||||
BObjectList<bigtime_t>
|
||||
BObjectList<bigtime_t, true>
|
||||
fKnown;
|
||||
bigtime_t fTotalDuration;
|
||||
PlaylistWindow& fParent;
|
||||
|
||||
@@ -72,7 +72,7 @@ TPeopleApp::TPeopleApp()
|
||||
:
|
||||
BApplication(APP_SIG),
|
||||
fWindowCount(0),
|
||||
fAttributes(20, true)
|
||||
fAttributes(20)
|
||||
{
|
||||
B_TRANSLATE_MARK_SYSTEM_NAME_VOID("People");
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
BString name;
|
||||
};
|
||||
|
||||
BObjectList<Attribute> fAttributes;
|
||||
BObjectList<Attribute, true> fAttributes;
|
||||
};
|
||||
|
||||
#endif // PEOPLE_APP_H
|
||||
|
||||
@@ -47,7 +47,7 @@ PersonView::PersonView(const char* name, const char* categoryAttribute,
|
||||
BGridView(),
|
||||
fLastModificationTime(0),
|
||||
fGroups(NULL),
|
||||
fControls(20, false),
|
||||
fControls(20),
|
||||
fCategoryAttribute(categoryAttribute),
|
||||
fPictureView(NULL),
|
||||
fSaving(false)
|
||||
|
||||
@@ -28,7 +28,7 @@ struct color_scheme gCustomColorScheme = {
|
||||
};
|
||||
|
||||
|
||||
BObjectList<const color_scheme>* gColorSchemes = NULL;
|
||||
BObjectList<const color_scheme, true>* gColorSchemes = NULL;
|
||||
|
||||
|
||||
bool
|
||||
|
||||
@@ -56,7 +56,7 @@ struct FindColorSchemeByName : public UnaryPredicate<const color_scheme> {
|
||||
};
|
||||
|
||||
extern color_scheme gCustomColorScheme;
|
||||
extern BObjectList<const color_scheme> *gColorSchemes;
|
||||
extern BObjectList<const color_scheme, true> *gColorSchemes;
|
||||
|
||||
const uint kANSIColorCount = 16;
|
||||
const uint kTermColorCount = 256;
|
||||
|
||||
@@ -270,7 +270,7 @@ SortByName(const color_scheme *lhs, const color_scheme *rhs)
|
||||
void
|
||||
PrefHandler::LoadThemes()
|
||||
{
|
||||
gColorSchemes = new BObjectList<const color_scheme>(10, true);
|
||||
gColorSchemes = new BObjectList<const color_scheme, true>(10);
|
||||
|
||||
BStringList paths;
|
||||
|
||||
|
||||
@@ -93,7 +93,7 @@ TerminalRoster::TerminalRoster()
|
||||
BHandler("terminal roster"),
|
||||
fLock("terminal roster"),
|
||||
fClipboard(TERM_SIGNATURE),
|
||||
fInfos(10, true),
|
||||
fInfos(10),
|
||||
fOurInfo(NULL),
|
||||
fLastCheckedTime(0),
|
||||
fListener(NULL),
|
||||
@@ -362,7 +362,7 @@ TerminalRoster::_UpdateInfos(bool checkApps)
|
||||
count = 0;
|
||||
|
||||
// create an info list from the message
|
||||
InfoList infos(10, true);
|
||||
InfoList infos(10);
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
// get the team's message
|
||||
BMessage teamData;
|
||||
|
||||
@@ -76,7 +76,7 @@ private:
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
|
||||
private:
|
||||
typedef BObjectList<Info> InfoList;
|
||||
typedef BObjectList<Info, true> InfoList;
|
||||
|
||||
private:
|
||||
status_t _UpdateInfos(bool checkApps);
|
||||
|
||||
Reference in New Issue
Block a user