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
77a99cc6
Commit
77a99cc6
authored
Jan 04, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CommandListBuilder: rename attributes
parent
fb337418
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
+35
-22
CommandListBuilder.cxx
src/CommandListBuilder.cxx
+7
-7
CommandListBuilder.hxx
src/CommandListBuilder.hxx
+28
-15
No files found.
src/CommandListBuilder.cxx
View file @
77a99cc6
...
...
@@ -25,23 +25,23 @@
void
CommandListBuilder
::
Reset
()
{
for
(
GSList
*
tmp
=
cmd_
list
;
tmp
!=
NULL
;
tmp
=
g_slist_next
(
tmp
))
for
(
GSList
*
tmp
=
list
;
tmp
!=
NULL
;
tmp
=
g_slist_next
(
tmp
))
g_free
(
tmp
->
data
);
g_slist_free
(
cmd_
list
);
g_slist_free
(
list
);
cmd_
list
=
nullptr
;
cmd_list_OK
=
-
1
;
list
=
nullptr
;
mode
=
Mode
::
DISABLED
;
}
bool
CommandListBuilder
::
Add
(
const
char
*
cmd
)
{
size_t
len
=
strlen
(
cmd
)
+
1
;
cmd_list_
size
+=
len
;
if
(
cmd_list_
size
>
client_max_command_list_size
)
size
+=
len
;
if
(
size
>
client_max_command_list_size
)
return
false
;
cmd_list
=
g_slist_prepend
(
cmd_
list
,
g_strdup
(
cmd
));
list
=
g_slist_prepend
(
list
,
g_strdup
(
cmd
));
return
true
;
}
src/CommandListBuilder.hxx
View file @
77a99cc6
...
...
@@ -25,23 +25,38 @@
class
CommandListBuilder
{
/**
*
for when in list mode
*
print OK after each command execution
*/
GSList
*
cmd_list
;
enum
class
Mode
{
/**
* Not active.
*/
DISABLED
=
-
1
,
/**
* Enabled in normal list mode.
*/
ENABLED
=
false
,
/**
* Enabled in "list_OK" mode.
*/
OK
=
true
,
}
mode
;
/**
*
print OK after each command execution
*
for when in list mode
*/
int
cmd_list_OK
;
GSList
*
list
;
/**
*
mem cmd_list consumes
*
Memory consumed by the list.
*/
size_t
cmd_list_
size
;
size_t
size
;
public
:
CommandListBuilder
()
:
cmd_list
(
nullptr
),
cmd_list_OK
(
-
1
),
cmd_list_
size
(
0
)
{}
:
mode
(
Mode
::
DISABLED
),
list
(
nullptr
),
size
(
0
)
{}
~
CommandListBuilder
()
{
Reset
();
}
...
...
@@ -50,9 +65,7 @@ public:
* Is a command list currently being built?
*/
bool
IsActive
()
const
{
assert
(
cmd_list_OK
>=
-
1
&&
cmd_list_OK
<=
1
);
return
cmd_list_OK
>=
0
;
return
mode
!=
Mode
::
DISABLED
;
}
/**
...
...
@@ -61,7 +74,7 @@ public:
bool
IsOKMode
()
const
{
assert
(
IsActive
());
return
(
bool
)
cmd_list_OK
;
return
(
bool
)
mode
;
}
/**
...
...
@@ -73,10 +86,10 @@ public:
* Begin building a command list.
*/
void
Begin
(
bool
ok
)
{
assert
(
cmd_
list
==
nullptr
);
assert
(
cmd_list_OK
==
-
1
);
assert
(
list
==
nullptr
);
assert
(
mode
==
Mode
::
DISABLED
);
cmd_list_OK
=
(
int
)
ok
;
mode
=
(
Mode
)
ok
;
}
/**
...
...
@@ -93,7 +106,7 @@ public:
/* for scalability reasons, we have prepended each new
command; now we have to reverse it to restore the
correct order */
return
cmd_list
=
g_slist_reverse
(
cmd_
list
);
return
list
=
g_slist_reverse
(
list
);
}
};
...
...
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