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
9e99e5be
Commit
9e99e5be
authored
Jan 03, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strset: delete obsolete library
parent
9023ba4a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
204 deletions
+0
-204
Makefile.am
Makefile.am
+0
-2
strset.c
src/strset.c
+0
-150
strset.h
src/strset.h
+0
-52
No files found.
Makefile.am
View file @
9e99e5be
...
...
@@ -170,7 +170,6 @@ mpd_headers = \
src/tag_id3.h
\
src/tag_rva2.h
\
src/tokenizer.h
\
src/strset.h
\
src/uri.h
\
src/utils.h
\
src/string_util.h
\
...
...
@@ -323,7 +322,6 @@ src_mpd_SOURCES = \
src/tokenizer.c
\
src/text_file.c
\
src/text_input_stream.c
\
src/strset.c
\
src/uri.c
\
src/utils.c
\
src/string_util.c
\
...
...
src/strset.c
deleted
100644 → 0
View file @
9023ba4a
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "strset.h"
#include <glib.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#define NUM_SLOTS 16384
struct
strset_slot
{
struct
strset_slot
*
next
;
const
char
*
value
;
};
struct
strset
{
unsigned
size
;
struct
strset_slot
*
current_slot
;
unsigned
next_slot
;
struct
strset_slot
slots
[
NUM_SLOTS
];
};
static
unsigned
calc_hash
(
const
char
*
p
)
{
unsigned
hash
=
5381
;
assert
(
p
!=
NULL
);
while
(
*
p
!=
0
)
hash
=
(
hash
<<
5
)
+
hash
+
*
p
++
;
return
hash
;
}
G_GNUC_MALLOC
struct
strset
*
strset_new
(
void
)
{
struct
strset
*
set
=
g_new0
(
struct
strset
,
1
);
return
set
;
}
void
strset_free
(
struct
strset
*
set
)
{
unsigned
i
;
for
(
i
=
0
;
i
<
NUM_SLOTS
;
++
i
)
{
struct
strset_slot
*
slot
=
set
->
slots
[
i
].
next
,
*
next
;
while
(
slot
!=
NULL
)
{
next
=
slot
->
next
;
g_free
(
slot
);
slot
=
next
;
}
}
g_free
(
set
);
}
void
strset_add
(
struct
strset
*
set
,
const
char
*
value
)
{
struct
strset_slot
*
base_slot
=
&
set
->
slots
[
calc_hash
(
value
)
%
NUM_SLOTS
];
struct
strset_slot
*
slot
=
base_slot
;
if
(
base_slot
->
value
==
NULL
)
{
/* empty slot - put into base_slot */
assert
(
base_slot
->
next
==
NULL
);
base_slot
->
value
=
value
;
++
set
->
size
;
return
;
}
for
(
slot
=
base_slot
;
slot
!=
NULL
;
slot
=
slot
->
next
)
if
(
strcmp
(
slot
->
value
,
value
)
==
0
)
/* found it - do nothing */
return
;
/* insert it into the slot chain */
slot
=
g_new
(
struct
strset_slot
,
1
);
slot
->
next
=
base_slot
->
next
;
slot
->
value
=
value
;
base_slot
->
next
=
slot
;
++
set
->
size
;
}
int
strset_get
(
const
struct
strset
*
set
,
const
char
*
value
)
{
const
struct
strset_slot
*
slot
=
&
set
->
slots
[
calc_hash
(
value
)];
if
(
slot
->
value
==
NULL
)
return
0
;
for
(
slot
=
slot
->
next
;
slot
!=
NULL
;
slot
=
slot
->
next
)
if
(
strcmp
(
slot
->
value
,
value
)
==
0
)
/* found it - do nothing */
return
1
;
return
0
;
}
unsigned
strset_size
(
const
struct
strset
*
set
)
{
return
set
->
size
;
}
void
strset_rewind
(
struct
strset
*
set
)
{
set
->
current_slot
=
NULL
;
set
->
next_slot
=
0
;
}
const
char
*
strset_next
(
struct
strset
*
set
)
{
if
(
set
->
current_slot
!=
NULL
&&
set
->
current_slot
->
next
!=
NULL
)
{
set
->
current_slot
=
set
->
current_slot
->
next
;
return
set
->
current_slot
->
value
;
}
while
(
set
->
next_slot
<
NUM_SLOTS
&&
set
->
slots
[
set
->
next_slot
].
value
==
NULL
)
++
set
->
next_slot
;
if
(
set
->
next_slot
>=
NUM_SLOTS
)
return
NULL
;
set
->
current_slot
=
&
set
->
slots
[
set
->
next_slot
++
];
return
set
->
current_slot
->
value
;
}
src/strset.h
deleted
100644 → 0
View file @
9023ba4a
/*
* Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/**
* "struct strset" is a hashed string set: you can add strings to this
* library, and it stores them as a set of unique strings. You can
* get the size of the set, and you can enumerate through all values.
*
* It is important to note that the strset does not copy the string
* values - it stores the exact pointers it was given in strset_add().
*/
#ifndef MPD_STRSET_H
#define MPD_STRSET_H
#include "gcc.h"
struct
strset
;
gcc_malloc
struct
strset
*
strset_new
(
void
);
void
strset_free
(
struct
strset
*
set
);
void
strset_add
(
struct
strset
*
set
,
const
char
*
value
);
int
strset_get
(
const
struct
strset
*
set
,
const
char
*
value
);
unsigned
strset_size
(
const
struct
strset
*
set
);
void
strset_rewind
(
struct
strset
*
set
);
const
char
*
strset_next
(
struct
strset
*
set
);
#endif
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