#include "bcsignals.h"
#include "bcwindowbase.h"
#include "bccolors.h"
+#include "cstrdup.h"
#include <string.h>
BC_MenuItem::BC_MenuItem(const char *text, const char *hotkey_text, int hotkey)
{
+ this->text = 0;
+ this->hotkey_text = 0;
reset();
if(text) set_text(text);
void BC_MenuItem::reset()
{
- text = new char[1];
- hotkey_text = new char[1];
- text[0] = 0;
- hotkey_text[0] = 0;
+ set_text("");
+ set_hotkey_text("");
icon = 0;
}
void BC_MenuItem::set_text(const char *text)
{
- if(this->text) delete [] this->text;
- this->text = new char[strlen(text) + 1];
- strcpy(this->text, text);
+ delete [] this->text;
+ this->text = cstrdup(text);
}
void BC_MenuItem::set_hotkey_text(const char *text)
{
- if(this->hotkey_text) delete [] this->hotkey_text;
- this->hotkey_text = new char[strlen(text) + 1];
- strcpy(this->hotkey_text, text);
+ delete [] this->hotkey_text;
+ this->hotkey_text = cstrdup(text);
}
int BC_MenuItem::deactivate_submenus(BC_MenuPopup *exclude)