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
f0be6a4b
Commit
f0be6a4b
authored
Jan 04, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MusicBuffer: allocate with new/delete
parent
bdab5d5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
30 deletions
+30
-30
MusicBuffer.cxx
src/MusicBuffer.cxx
+30
-30
No files found.
src/MusicBuffer.cxx
View file @
f0be6a4b
...
...
@@ -37,49 +37,49 @@ struct music_buffer {
#ifndef NDEBUG
unsigned
num_allocated
;
#endif
};
struct
music_buffer
*
music_buffer_new
(
unsigned
num_chunks
)
{
struct
music_buffer
*
buffer
;
struct
music_chunk
*
chunk
;
assert
(
num_chunks
>
0
);
buffer
=
g_new
(
struct
music_buffer
,
1
);
music_buffer
(
unsigned
_num_chunks
)
:
chunks
(
g_new
(
struct
music_chunk
,
_num_chunks
)),
num_chunks
(
_num_chunks
),
available
(
chunks
),
mutex
(
g_mutex_new
())
#ifndef NDEBUG
,
num_allocated
(
0
)
#endif
{
assert
(
num_chunks
>
0
);
buffer
->
chunks
=
g_new
(
struct
music_chunk
,
num_chunks
)
;
buffer
->
num_chunks
=
num_
chunks
;
struct
music_chunk
*
chunk
;
chunk
=
available
=
chunks
;
chunk
=
buffer
->
available
=
buffer
->
chunks
;
for
(
unsigned
i
=
1
;
i
<
num_chunks
;
++
i
)
{
chunk
->
next
=
&
chunks
[
i
];
chunk
=
chunk
->
next
;
}
for
(
unsigned
i
=
1
;
i
<
num_chunks
;
++
i
)
{
chunk
->
next
=
&
buffer
->
chunks
[
i
];
chunk
=
chunk
->
next
;
chunk
->
next
=
nullptr
;
}
chunk
->
next
=
NULL
;
~
music_buffer
()
{
assert
(
chunks
!=
nullptr
);
assert
(
num_chunks
>
0
);
assert
(
num_allocated
==
0
);
buffer
->
mutex
=
g_mutex_new
();
#ifndef NDEBUG
buffer
->
num_allocated
=
0
;
#endif
g_mutex_free
(
mutex
);
g_free
(
chunks
);
}
};
return
buffer
;
struct
music_buffer
*
music_buffer_new
(
unsigned
num_chunks
)
{
return
new
music_buffer
(
num_chunks
);
}
void
music_buffer_free
(
struct
music_buffer
*
buffer
)
{
assert
(
buffer
->
chunks
!=
NULL
);
assert
(
buffer
->
num_chunks
>
0
);
assert
(
buffer
->
num_allocated
==
0
);
g_mutex_free
(
buffer
->
mutex
);
g_free
(
buffer
->
chunks
);
g_free
(
buffer
);
delete
buffer
;
}
unsigned
...
...
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