Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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
wine
wine-cw
Commits
ad02173d
Commit
ad02173d
authored
Jun 18, 2006
by
Eric Pouech
Committed by
Alexandre Julliard
Jun 20, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Added another basic type for storage: the sparse array.
parent
b3196001
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
0 deletions
+96
-0
dbghelp_private.h
dlls/dbghelp/dbghelp_private.h
+11
-0
storage.c
dlls/dbghelp/storage.c
+85
-0
No files found.
dlls/dbghelp/dbghelp_private.h
View file @
ad02173d
...
...
@@ -63,6 +63,17 @@ void* vector_add(struct vector* v, struct pool* pool);
void
*
vector_iter_up
(
const
struct
vector
*
v
,
void
*
elt
);
void
*
vector_iter_down
(
const
struct
vector
*
v
,
void
*
elt
);
struct
sparse_array
{
struct
vector
key2index
;
struct
vector
elements
;
};
void
sparse_array_init
(
struct
sparse_array
*
sa
,
unsigned
elt_sz
,
unsigned
bucket_sz
);
void
*
sparse_array_find
(
const
struct
sparse_array
*
sa
,
unsigned
long
idx
);
void
*
sparse_array_add
(
struct
sparse_array
*
sa
,
unsigned
long
key
,
struct
pool
*
pool
);
unsigned
sparse_array_length
(
const
struct
sparse_array
*
sa
);
struct
hash_table_elt
{
const
char
*
name
;
...
...
dlls/dbghelp/storage.c
View file @
ad02173d
...
...
@@ -225,6 +225,91 @@ void* vector_iter_down(const struct vector* v, void* elt)
return
vector_at
(
v
,
pos
-
1
);
}
/* We construct the sparse array as two vectors (of equal size)
* The first vector (key2index) is the lookup table between the key and
* an index in the second vector (elements)
* When inserting an element, it's always appended in second vector (and
* never moved in memory later on), only the first vector is reordered
*/
struct
key2index
{
unsigned
long
key
;
unsigned
index
;
};
void
sparse_array_init
(
struct
sparse_array
*
sa
,
unsigned
elt_sz
,
unsigned
bucket_sz
)
{
vector_init
(
&
sa
->
key2index
,
sizeof
(
struct
key2index
),
bucket_sz
);
vector_init
(
&
sa
->
elements
,
elt_sz
,
bucket_sz
);
}
/******************************************************************
* spare_array_lookup
*
* Returns the first index which key is >= at passed key
*/
static
struct
key2index
*
spare_array_lookup
(
const
struct
sparse_array
*
sa
,
unsigned
long
key
,
unsigned
*
idx
)
{
struct
key2index
*
pk2i
;
/* FIXME: should use bsearch here */
for
(
*
idx
=
0
;
*
idx
<
sa
->
elements
.
num_elts
;
(
*
idx
)
++
)
{
pk2i
=
vector_at
(
&
sa
->
key2index
,
*
idx
);
if
(
pk2i
&&
pk2i
->
key
>=
key
)
return
pk2i
;
}
return
NULL
;
}
void
*
sparse_array_find
(
const
struct
sparse_array
*
sa
,
unsigned
long
key
)
{
unsigned
idx
;
struct
key2index
*
pk2i
;
if
((
pk2i
=
spare_array_lookup
(
sa
,
key
,
&
idx
))
&&
pk2i
->
key
==
key
)
return
vector_at
(
&
sa
->
elements
,
pk2i
->
index
);
return
NULL
;
}
void
*
sparse_array_add
(
struct
sparse_array
*
sa
,
unsigned
long
key
,
struct
pool
*
pool
)
{
unsigned
idx
,
i
;
struct
key2index
*
pk2i
;
struct
key2index
*
to
;
pk2i
=
spare_array_lookup
(
sa
,
key
,
&
idx
);
if
(
pk2i
&&
pk2i
->
key
==
key
)
{
FIXME
(
"re adding an existing key
\n
"
);
return
NULL
;
}
to
=
vector_add
(
&
sa
->
key2index
,
pool
);
if
(
pk2i
)
{
/* we need to shift vector's content... */
/* let's do it brute force... (FIXME) */
assert
(
sa
->
key2index
.
num_elts
>=
2
);
for
(
i
=
sa
->
key2index
.
num_elts
-
1
;
i
>
idx
;
i
--
)
{
pk2i
=
vector_at
(
&
sa
->
key2index
,
i
-
1
);
*
to
=
*
pk2i
;
to
=
pk2i
;
}
}
to
->
key
=
key
;
to
->
index
=
sa
->
elements
.
num_elts
;
return
vector_add
(
&
sa
->
elements
,
pool
);
}
unsigned
sparse_array_length
(
const
struct
sparse_array
*
sa
)
{
return
sa
->
elements
.
num_elts
;
}
unsigned
hash_table_hash
(
const
char
*
name
,
unsigned
num_buckets
)
{
unsigned
hash
=
0
;
...
...
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