Skip to content

Commit

Permalink
Use C++11 inline initialisation for class members.
Browse files Browse the repository at this point in the history
  • Loading branch information
SadieCat committed Feb 6, 2020
1 parent e628fa9 commit 3420416
Show file tree
Hide file tree
Showing 96 changed files with 296 additions and 493 deletions.
10 changes: 5 additions & 5 deletions include/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class CoreExport interfacebase
*/
class CoreExport refcountbase
{
mutable unsigned int refcount;
mutable unsigned int refcount = 0;
public:
refcountbase();
virtual ~refcountbase();
Expand All @@ -112,9 +112,9 @@ class CoreExport refcountbase
*/
class CoreExport usecountbase
{
mutable unsigned int usecount;
mutable unsigned int usecount = 0;
public:
usecountbase() : usecount(0) { }
usecountbase() = default;
~usecountbase();
inline unsigned int GetUseCount() const { return usecount; }
inline void refcount_inc() const { usecount++; }
Expand All @@ -128,9 +128,9 @@ class CoreExport usecountbase
template <typename T>
class reference
{
T* value;
T* value = nullptr;
public:
reference() : value(0) { }
reference() = default;
reference(T* v) : value(v) { if (value) value->refcount_inc(); }
reference(const reference<T>& v) : value(v.value) { if (value) value->refcount_inc(); }
reference<T>& operator=(const reference<T>& other)
Expand Down
2 changes: 1 addition & 1 deletion include/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class CoreExport Channel : public Extensible
/** Time topic was set.
* If no topic was ever set, this will be equal to Channel::created
*/
time_t topicset;
time_t topicset = 0;

/** The last user to set the topic.
* If this member is an empty string, no topic was ever set.
Expand Down
22 changes: 6 additions & 16 deletions include/clientprotocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
operator const std::string&() const { return (owned ? *str : *ptr); }

Param()
: ptr(NULL)
: ptr(nullptr)
, owned(false)
{
}
Expand Down Expand Up @@ -285,9 +285,9 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
ParamList params;
TagMap tags;
std::string command;
bool msginit_done;
bool msginit_done = false;
mutable SerializedList serlist;
bool sideeffect;
bool sideeffect = false;

protected:
/** Set command string.
Expand All @@ -309,8 +309,6 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
Message(const char* cmd, User* Sourceuser = NULL)
: ClientProtocol::MessageSource(Sourceuser)
, command(cmd ? cmd : std::string())
, msginit_done(false)
, sideeffect(false)
{
params.reserve(8);
serlist.reserve(8);
Expand All @@ -326,8 +324,6 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
Message(const char* cmd, const std::string& Sourcestr, User* Sourceuser = NULL)
: ClientProtocol::MessageSource(Sourcestr, Sourceuser)
, command(cmd ? cmd : std::string())
, msginit_done(false)
, sideeffect(false)
{
params.reserve(8);
serlist.reserve(8);
Expand Down Expand Up @@ -462,19 +458,16 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource
class ClientProtocol::Event
{
EventProvider* event;
Message* initialmsg;
const MessageList* initialmsglist;
bool eventinit_done;
Message* initialmsg = nullptr;
const MessageList* initialmsglist = nullptr;
bool eventinit_done = false;

public:
/** Constructor.
* @param protoeventprov Protocol event provider the event is an instance of.
*/
Event(EventProvider& protoeventprov)
: event(&protoeventprov)
, initialmsg(NULL)
, initialmsglist(NULL)
, eventinit_done(false)
{
}

Expand All @@ -484,9 +477,6 @@ class ClientProtocol::Event
*/
Event(EventProvider& protoeventprov, ClientProtocol::Message& msg)
: event(&protoeventprov)
, initialmsg(&msg)
, initialmsglist(NULL)
, eventinit_done(false)
{
}

Expand Down
10 changes: 3 additions & 7 deletions include/commands/cmd_whowas.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,6 @@ namespace WhoWas
*/
bool IsEnabled() const;

/** Constructor
*/
Manager();

/** Destructor
*/
~Manager();
Expand All @@ -162,16 +158,16 @@ namespace WhoWas

/** Max number of WhoWas entries per user.
*/
unsigned int GroupSize;
unsigned int GroupSize = 0;

/** Max number of cumulative user-entries in WhoWas.
* When max reached and added to, push out oldest entry FIFO style.
*/
unsigned int MaxGroups;
unsigned int MaxGroups = 0;

/** Max seconds a user is kept in WhoWas before being pruned.
*/
unsigned int MaxKeep;
unsigned int MaxKeep = 0;

/** Shrink all data structures to honor the current settings
*/
Expand Down
4 changes: 2 additions & 2 deletions include/configreader.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ class CoreExport ServerConfig
bool HideBans;

/** True if raw I/O is being logged */
bool RawLog;
bool RawLog = false;

/** Set to a non-empty string to obfuscate server names. */
std::string HideServer;
Expand Down Expand Up @@ -455,7 +455,7 @@ class CoreExport ServerConfig

/** If this value is true, snotices will not stack when repeats are sent
*/
bool NoSnoticeStack;
bool NoSnoticeStack = false;
};

/** The background thread for config reading, so that reading from executable includes
Expand Down
12 changes: 6 additions & 6 deletions include/ctables.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class CoreExport CommandBase : public ServiceProvider

/** User flags needed to execute the command or 0
*/
unsigned char flags_needed;
unsigned char flags_needed = 0;

/** Minimum number of parameters command takes
*/
Expand All @@ -164,11 +164,11 @@ class CoreExport CommandBase : public ServiceProvider

/** used by /stats m
*/
unsigned long use_count;
unsigned long use_count = 0;

/** True if the command can be issued before registering
*/
bool works_before_reg;
bool works_before_reg = false;

/** True if the command allows an empty last parameter.
* When false and the last parameter is empty, it's popped BEFORE
Expand All @@ -177,7 +177,7 @@ class CoreExport CommandBase : public ServiceProvider
* param).
* True by default
*/
bool allow_empty_last_param;
bool allow_empty_last_param = true;

/** Syntax string for the command, displayed if non-empty string.
* This takes place of the text in the 'not enough parameters' numeric.
Expand All @@ -191,7 +191,7 @@ class CoreExport CommandBase : public ServiceProvider

/** How many seconds worth of penalty does this command have?
*/
unsigned int Penalty;
unsigned int Penalty = 1;

/** Create a new command.
* @param me The module which created this command.
Expand Down Expand Up @@ -227,7 +227,7 @@ class CoreExport Command : public CommandBase
/** If true, the command will not be forwarded by the linking module even if it comes via ENCAP.
* Can be used to forward commands before their effects.
*/
bool force_manual_route;
bool force_manual_route = false;

Command(Module* me, const std::string& cmd, unsigned int minpara = 0, unsigned int maxpara = 0);

Expand Down
4 changes: 2 additions & 2 deletions include/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ class CoreExport DLLManager : public classbase

/** The module library handle. */
#ifdef _WIN32
HMODULE lib;
HMODULE lib = INVALID_HANDLE_VALUE;
#else
void* lib;
void* lib = nullptr;
#endif

/** The filename of the module library. */
Expand Down
4 changes: 2 additions & 2 deletions include/dynref.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ class CoreExport dynamic_reference_base : public interfacebase, public insp::int

private:
std::string name;
CaptureHook* hook;
CaptureHook* hook = nullptr;
void resolve();
protected:
ServiceProvider* value;
ServiceProvider* value = nullptr;
public:
ModuleRef creator;
dynamic_reference_base(Module* Creator, const std::string& Name);
Expand Down
4 changes: 2 additions & 2 deletions include/fileutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ class CoreExport FileReader
std::vector<std::string> lines;

/** File size in bytes. */
unsigned long totalSize;
unsigned long totalSize = 0;

public:
/** Initializes a new file reader. */
FileReader() : totalSize(0) { }
FileReader() = default;

/** Initializes a new file reader and reads the specified file.
* @param filename The file to read into memory.
Expand Down
4 changes: 2 additions & 2 deletions include/hashcomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace irc
char sep;
/** Current string position
*/
size_t pos;
size_t pos = 0;
/** If set then GetToken() can return an empty string
*/
bool allow_empty;
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace irc
std::string message;

/** The current position within the message. */
size_t position;
size_t position = 0;

public:
/** Create a tokenstream and fill it with the provided data. */
Expand Down
Loading

0 comments on commit 3420416

Please sign in to comment.