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
28b896fe
Commit
28b896fe
authored
10 years ago
by
Keisuke Kuroyanagi
Committed by
Android (Google) Code Review
10 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Use nullptr instead of MmappedBufferPtr(nullptr)."
parents
ee599754
2dc8e36f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.cpp
+5
-5
5 additions, 5 deletions
...rc/suggest/policyimpl/dictionary/utils/mmapped_buffer.cpp
with
5 additions
and
5 deletions
native/jni/src/suggest/policyimpl/dictionary/utils/mmapped_buffer.cpp
+
5
−
5
View file @
28b896fe
...
@@ -33,7 +33,7 @@ namespace latinime {
...
@@ -33,7 +33,7 @@ namespace latinime {
const
int
mmapFd
=
open
(
path
,
O_RDONLY
);
const
int
mmapFd
=
open
(
path
,
O_RDONLY
);
if
(
mmapFd
<
0
)
{
if
(
mmapFd
<
0
)
{
AKLOGE
(
"DICT: Can't open the source. path=%s errno=%d"
,
path
,
errno
);
AKLOGE
(
"DICT: Can't open the source. path=%s errno=%d"
,
path
,
errno
);
return
MmappedBufferPtr
(
nullptr
)
;
return
nullptr
;
}
}
const
int
pagesize
=
sysconf
(
_SC_PAGESIZE
);
const
int
pagesize
=
sysconf
(
_SC_PAGESIZE
);
const
int
offset
=
bufferOffset
%
pagesize
;
const
int
offset
=
bufferOffset
%
pagesize
;
...
@@ -45,13 +45,13 @@ namespace latinime {
...
@@ -45,13 +45,13 @@ namespace latinime {
if
(
mmappedBuffer
==
MAP_FAILED
)
{
if
(
mmappedBuffer
==
MAP_FAILED
)
{
AKLOGE
(
"DICT: Can't mmap dictionary. errno=%d"
,
errno
);
AKLOGE
(
"DICT: Can't mmap dictionary. errno=%d"
,
errno
);
close
(
mmapFd
);
close
(
mmapFd
);
return
MmappedBufferPtr
(
nullptr
)
;
return
nullptr
;
}
}
uint8_t
*
const
buffer
=
static_cast
<
uint8_t
*>
(
mmappedBuffer
)
+
offset
;
uint8_t
*
const
buffer
=
static_cast
<
uint8_t
*>
(
mmappedBuffer
)
+
offset
;
if
(
!
buffer
)
{
if
(
!
buffer
)
{
AKLOGE
(
"DICT: buffer is null"
);
AKLOGE
(
"DICT: buffer is null"
);
close
(
mmapFd
);
close
(
mmapFd
);
return
MmappedBufferPtr
(
nullptr
)
;
return
nullptr
;
}
}
return
MmappedBufferPtr
(
new
MmappedBuffer
(
buffer
,
bufferSize
,
mmappedBuffer
,
alignedSize
,
return
MmappedBufferPtr
(
new
MmappedBuffer
(
buffer
,
bufferSize
,
mmappedBuffer
,
alignedSize
,
mmapFd
,
isUpdatable
));
mmapFd
,
isUpdatable
));
...
@@ -61,7 +61,7 @@ namespace latinime {
...
@@ -61,7 +61,7 @@ namespace latinime {
const
char
*
const
path
,
const
bool
isUpdatable
)
{
const
char
*
const
path
,
const
bool
isUpdatable
)
{
const
int
fileSize
=
FileUtils
::
getFileSize
(
path
);
const
int
fileSize
=
FileUtils
::
getFileSize
(
path
);
if
(
fileSize
==
-
1
)
{
if
(
fileSize
==
-
1
)
{
return
MmappedBufferPtr
(
nullptr
)
;
return
nullptr
;
}
else
if
(
fileSize
==
0
)
{
}
else
if
(
fileSize
==
0
)
{
return
MmappedBufferPtr
(
new
MmappedBuffer
(
isUpdatable
));
return
MmappedBufferPtr
(
new
MmappedBuffer
(
isUpdatable
));
}
else
{
}
else
{
...
@@ -76,7 +76,7 @@ namespace latinime {
...
@@ -76,7 +76,7 @@ namespace latinime {
const
int
filePathLength
=
snprintf
(
filePath
,
filePathBufferSize
,
"%s%s"
,
dirPath
,
const
int
filePathLength
=
snprintf
(
filePath
,
filePathBufferSize
,
"%s%s"
,
dirPath
,
fileName
);
fileName
);
if
(
filePathLength
>=
filePathBufferSize
)
{
if
(
filePathLength
>=
filePathBufferSize
)
{
return
MmappedBufferPtr
(
nullptr
)
;
return
nullptr
;
}
}
return
openBuffer
(
filePath
,
isUpdatable
);
return
openBuffer
(
filePath
,
isUpdatable
);
}
}
...
...
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