Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3cdd01aa
Commit
3cdd01aa
authored
Jan 30, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConfigData: use std::vector for the block_param list
parent
d2519544
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
31 deletions
+17
-31
ConfigData.cxx
src/ConfigData.cxx
+9
-23
ConfigData.hxx
src/ConfigData.hxx
+5
-3
ConfigGlobal.cxx
src/ConfigGlobal.cxx
+3
-5
No files found.
src/ConfigData.cxx
View file @
3cdd01aa
...
@@ -43,8 +43,6 @@ config_new_param(const char *value, int line)
...
@@ -43,8 +43,6 @@ config_new_param(const char *value, int line)
ret
->
line
=
line
;
ret
->
line
=
line
;
ret
->
num_block_params
=
0
;
ret
->
block_params
=
NULL
;
ret
->
used
=
false
;
ret
->
used
=
false
;
return
ret
;
return
ret
;
...
@@ -55,14 +53,11 @@ config_param_free(struct config_param *param)
...
@@ -55,14 +53,11 @@ config_param_free(struct config_param *param)
{
{
g_free
(
param
->
value
);
g_free
(
param
->
value
);
for
(
unsigned
i
=
0
;
i
<
param
->
num_block_params
;
i
++
)
{
for
(
auto
&
i
:
param
->
block_params
)
{
g_free
(
param
->
block_params
[
i
]
.
name
);
g_free
(
i
.
name
);
g_free
(
param
->
block_params
[
i
]
.
value
);
g_free
(
i
.
value
);
}
}
if
(
param
->
num_block_params
)
g_free
(
param
->
block_params
);
delete
param
;
delete
param
;
}
}
...
@@ -70,18 +65,10 @@ void
...
@@ -70,18 +65,10 @@ void
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
config_add_block_param
(
struct
config_param
*
param
,
const
char
*
name
,
const
char
*
value
,
int
line
)
const
char
*
value
,
int
line
)
{
{
struct
block_param
*
bp
;
assert
(
config_get_block_param
(
param
,
name
)
==
NULL
);
assert
(
config_get_block_param
(
param
,
name
)
==
NULL
);
param
->
num_block_params
++
;
param
->
block_params
.
push_back
(
block_param
());
struct
block_param
*
bp
=
&
param
->
block_params
.
back
();
param
->
block_params
=
(
struct
block_param
*
)
g_realloc
(
param
->
block_params
,
param
->
num_block_params
*
sizeof
(
param
->
block_params
[
0
]));
bp
=
&
param
->
block_params
[
param
->
num_block_params
-
1
];
bp
->
name
=
g_strdup
(
name
);
bp
->
name
=
g_strdup
(
name
);
bp
->
value
=
g_strdup
(
value
);
bp
->
value
=
g_strdup
(
value
);
...
@@ -95,11 +82,10 @@ config_get_block_param(const struct config_param * param, const char *name)
...
@@ -95,11 +82,10 @@ config_get_block_param(const struct config_param * param, const char *name)
if
(
param
==
NULL
)
if
(
param
==
NULL
)
return
NULL
;
return
NULL
;
for
(
unsigned
i
=
0
;
i
<
param
->
num_block_params
;
i
++
)
{
for
(
auto
&
i
:
param
->
block_params
)
{
if
(
0
==
strcmp
(
name
,
param
->
block_params
[
i
].
name
))
{
if
(
0
==
strcmp
(
name
,
i
.
name
))
{
struct
block_param
*
bp
=
&
param
->
block_params
[
i
];
i
.
used
=
true
;
bp
->
used
=
true
;
return
&
i
;
return
bp
;
}
}
}
}
...
...
src/ConfigData.hxx
View file @
3cdd01aa
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#ifdef __cplusplus
#ifdef __cplusplus
#include <glib.h>
#include <glib.h>
#include <array>
#include <array>
#include <vector>
#endif
#endif
#include <stdbool.h>
#include <stdbool.h>
...
@@ -42,7 +43,7 @@ struct block_param {
...
@@ -42,7 +43,7 @@ struct block_param {
* This flag is false when nobody has queried the value of
* This flag is false when nobody has queried the value of
* this option yet.
* this option yet.
*/
*/
bool
used
;
mutable
bool
used
;
};
};
#endif
#endif
...
@@ -51,14 +52,15 @@ struct config_param {
...
@@ -51,14 +52,15 @@ struct config_param {
char
*
value
;
char
*
value
;
unsigned
int
line
;
unsigned
int
line
;
struct
block_param
*
block_params
;
#ifdef __cplusplus
unsigned
num_
block_params
;
std
::
vector
<
block_param
>
block_params
;
/**
/**
* This flag is false when nobody has queried the value of
* This flag is false when nobody has queried the value of
* this option yet.
* this option yet.
*/
*/
bool
used
;
bool
used
;
#endif
};
};
#ifdef __cplusplus
#ifdef __cplusplus
...
...
src/ConfigGlobal.cxx
View file @
3cdd01aa
...
@@ -76,12 +76,10 @@ config_param_check(gpointer data, G_GNUC_UNUSED gpointer user_data)
...
@@ -76,12 +76,10 @@ config_param_check(gpointer data, G_GNUC_UNUSED gpointer user_data)
Silently ignore it here. */
Silently ignore it here. */
return
;
return
;
for
(
unsigned
i
=
0
;
i
<
param
->
num_block_params
;
i
++
)
{
for
(
const
auto
&
i
:
param
->
block_params
)
{
struct
block_param
*
bp
=
&
param
->
block_params
[
i
];
if
(
!
i
.
used
)
if
(
!
bp
->
used
)
g_warning
(
"option '%s' on line %i was not recognized"
,
g_warning
(
"option '%s' on line %i was not recognized"
,
bp
->
name
,
bp
->
line
);
i
.
name
,
i
.
line
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment