Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
97a553ae
Commit
97a553ae
authored
11 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Fix wrong dereference reading code.
Bug: 12164855 Change-Id: I26faf27edfa303510197bccaa3521578f649741d
parent
b54c747d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/makedict/SparseTableContentReader.java
+23
-17
23 additions, 17 deletions
.../inputmethod/latin/makedict/SparseTableContentReader.java
with
23 additions
and
17 deletions
java/src/com/android/inputmethod/latin/makedict/SparseTableContentReader.java
+
23
−
17
View file @
97a553ae
...
...
@@ -58,17 +58,17 @@ public class SparseTableContentReader {
* @param blockSize the block size of the content table.
* @param baseDir the directory which contains the files of the content table.
* @param contentFilenames the file names of content files.
* @param content
Id
s the ids of contents. These ids are used for a suffix of a name of
* @param content
Suffixe
s the ids of contents. These ids are used for a suffix of a name of
* address files and content files.
* @param factory the DictionaryBufferFactory which is used for opening the files.
*/
public
SparseTableContentReader
(
final
String
name
,
final
int
blockSize
,
final
File
baseDir
,
final
String
[]
contentFilenames
,
final
String
[]
content
Id
s
,
final
String
[]
contentFilenames
,
final
String
[]
content
Suffixe
s
,
final
DictionaryBufferFactory
factory
)
{
if
(
contentFilenames
.
length
!=
content
Id
s
.
length
)
{
if
(
contentFilenames
.
length
!=
content
Suffixe
s
.
length
)
{
throw
new
RuntimeException
(
"The length of contentFilenames and the length of"
+
" content
Id
s are different "
+
contentFilenames
.
length
+
", "
+
content
Id
s
.
length
);
+
" content
Suffixe
s are different "
+
contentFilenames
.
length
+
", "
+
content
Suffixe
s
.
length
);
}
mBlockSize
=
blockSize
;
mBaseDir
=
baseDir
;
...
...
@@ -79,8 +79,8 @@ public class SparseTableContentReader {
mContentFiles
=
new
File
[
mContentCount
];
for
(
int
i
=
0
;
i
<
mContentCount
;
++
i
)
{
mAddressTableFiles
[
i
]
=
new
File
(
mBaseDir
,
name
+
FormatSpec
.
CONTENT_TABLE_FILE_SUFFIX
+
content
Id
s
[
i
]);
mContentFiles
[
i
]
=
new
File
(
mBaseDir
,
contentFilenames
[
i
]
+
content
Id
s
[
i
]);
name
+
FormatSpec
.
CONTENT_TABLE_FILE_SUFFIX
+
content
Suffixe
s
[
i
]);
mContentFiles
[
i
]
=
new
File
(
mBaseDir
,
contentFilenames
[
i
]
+
content
Suffixe
s
[
i
]);
}
mAddressTableBuffers
=
new
DictBuffer
[
mContentCount
];
mContentBuffers
=
new
DictBuffer
[
mContentCount
];
...
...
@@ -94,27 +94,33 @@ public class SparseTableContentReader {
}
}
protected
void
read
(
final
int
contentIndex
,
final
int
index
,
/**
* Calls the read() callback of the reader with the appropriate buffer appropriately positioned.
* @param contentNumber the index in the original contentFilenames[] array.
* @param terminalId the terminal ID to read.
* @param reader the reader on which to call the callback.
*/
protected
void
read
(
final
int
contentNumber
,
final
int
terminalId
,
final
SparseTableContentReaderInterface
reader
)
{
if
(
index
<
0
||
(
index
/
mBlockSize
)
*
SparseTable
.
SIZE_OF_INT_IN_BYTES
if
(
terminalId
<
0
||
(
terminalId
/
mBlockSize
)
*
SparseTable
.
SIZE_OF_INT_IN_BYTES
>=
mLookupTableBuffer
.
limit
())
{
return
;
}
mLookupTableBuffer
.
position
((
index
/
mBlockSize
)
*
SparseTable
.
SIZE_OF_INT_IN_BYTES
);
final
int
pos
InAddressTable
=
mLookupTableBuffer
.
readInt
();
if
(
pos
InAddressTable
==
SparseTable
.
NOT_EXIST
)
{
mLookupTableBuffer
.
position
((
terminalId
/
mBlockSize
)
*
SparseTable
.
SIZE_OF_INT_IN_BYTES
);
final
int
index
InAddressTable
=
mLookupTableBuffer
.
readInt
();
if
(
index
InAddressTable
==
SparseTable
.
NOT_EXIST
)
{
return
;
}
mAddressTableBuffers
[
content
Index
].
position
(
(
pos
InAddressTable
+
index
%
mBlockSize
)
*
SparseTable
.
SIZE_OF_INT_IN_BYTES
);
final
int
address
=
mAddressTableBuffers
[
content
Index
].
readInt
();
mAddressTableBuffers
[
content
Number
].
position
(
SparseTable
.
SIZE_OF_INT_IN_BYTES
*
((
index
InAddressTable
*
mBlockSize
)
+
(
terminalId
%
mBlockSize
))
);
final
int
address
=
mAddressTableBuffers
[
content
Number
].
readInt
();
if
(
address
==
SparseTable
.
NOT_EXIST
)
{
return
;
}
mContentBuffers
[
content
Index
].
position
(
address
);
reader
.
read
(
mContentBuffers
[
content
Index
]);
mContentBuffers
[
content
Number
].
position
(
address
);
reader
.
read
(
mContentBuffers
[
content
Number
]);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment