summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menuitems.c27
-rw-r--r--menuitems.h10
2 files changed, 11 insertions, 26 deletions
diff --git a/menuitems.c b/menuitems.c
index 7aa80d0c..eb2b5cf4 100644
--- a/menuitems.c
+++ b/menuitems.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.c,v 1.8 2007-06-12 15:11:19 phintuka Exp $
+ * $Id: menuitems.c,v 1.9 2007-06-21 10:00:29 phintuka Exp $
*
*/
@@ -21,29 +21,22 @@ cMenuEditTypedIntItem::cMenuEditTypedIntItem(const char *Name, const char *Type,
const char *MinString, const char *MaxString)
:cMenuEditIntItem(Name,Value,Min,Max,MinString,MaxString)
{
- type = strdup(Type?Type:"");
- zeroString = ZeroString ? strdup(ZeroString) : NULL;
+ type = Type ? Type : "";
+ zeroString = ZeroString ? ZeroString : NULL;
Set();
}
-cMenuEditTypedIntItem::~cMenuEditTypedIntItem()
-{
- free(type);
- if(zeroString)
- free(zeroString);
-}
-
void cMenuEditTypedIntItem::Set(void)
{
char buf[64];
- if(zeroString && *value == 0)
+ if(*value == 0 && *zeroString)
SetValue(zeroString);
else if (minString && *value == min)
SetValue(minString);
else if (maxString && *value == max)
SetValue(maxString);
else {
- snprintf(buf, sizeof(buf), "%d %s", *value, type);
+ snprintf(buf, sizeof(buf), "%d %s", *value, *type);
buf[sizeof(buf)-1] = 0;
SetValue(buf);
}
@@ -110,20 +103,14 @@ cMenuEditFpIntItem::cMenuEditFpIntItem(const char *Name, int *Value, int Min, in
:cMenuEditIntItem(Name,Value,Min,Max,MinString,MaxString)
{
decimals = Decimals;
- zeroString = ZeroString ? strdup(ZeroString) : NULL;
+ zeroString = ZeroString ? ZeroString : NULL;
Set();
}
-cMenuEditFpIntItem::~cMenuEditFpIntItem()
-{
- if(zeroString)
- free(zeroString);
-}
-
void cMenuEditFpIntItem::Set(void)
{
char buf[64];
- if(zeroString && *value == 0)
+ if(*value == 0 && *zeroString)
SetValue(zeroString);
else if (minString && *value == min)
SetValue(minString);
diff --git a/menuitems.h b/menuitems.h
index 51c22710..cb158881 100644
--- a/menuitems.h
+++ b/menuitems.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.h,v 1.6 2007-06-12 15:11:19 phintuka Exp $
+ * $Id: menuitems.h,v 1.7 2007-06-21 10:00:29 phintuka Exp $
*
*/
@@ -18,8 +18,8 @@
class cMenuEditTypedIntItem : public cMenuEditIntItem
{
protected:
- char *type;
- char *zeroString;
+ cString type;
+ cString zeroString;
virtual void Set(void);
@@ -27,7 +27,6 @@ class cMenuEditTypedIntItem : public cMenuEditIntItem
cMenuEditTypedIntItem(const char *Name, const char *Type, int *Value,
int Min = 0, int Max = INT_MAX, const char *ZeroString = NULL,
const char *MinString = NULL, const char *MaxString = NULL);
- ~cMenuEditTypedIntItem();
};
// --- cMenuEditOddIntItem -------------------------------------------------
@@ -48,7 +47,7 @@ class cMenuEditFpIntItem : public cMenuEditIntItem
{
protected:
int decimals;
- char *zeroString;
+ cString zeroString;
virtual void Set(void);
@@ -56,7 +55,6 @@ class cMenuEditFpIntItem : public cMenuEditIntItem
cMenuEditFpIntItem(const char *Name, int *Value, int Min = 1, int Max = INT_MAX,
int Decimals = 1, const char *ZeroString = NULL,
const char *MinString = NULL, const char *MaxString = NULL);
- ~cMenuEditFpIntItem();
};