Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Utils
KWSys
Commits
8717ac15
Commit
8717ac15
authored
7 years ago
by
Rolf Eike Beer
Browse files
Options
Downloads
Patches
Plain Diff
DynamicLoader: use std::string instead of strcpy() + strcat()
parent
239bc737
No related branches found
Branches containing commit
No related tags found
1 merge request
!59
DynamicLoader: use std::string instead of strcpy() + strcat()
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DynamicLoader.cxx
+4
-13
4 additions, 13 deletions
DynamicLoader.cxx
with
4 additions
and
13 deletions
DynamicLoader.cxx
+
4
−
13
View file @
8717ac15
...
...
@@ -163,17 +163,13 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
{
void
*
result
=
0
;
// Need to prepend symbols with '_' on Apple-gcc compilers
size_t
len
=
sym
.
size
();
char
*
rsym
=
new
char
[
len
+
1
+
1
];
strcpy
(
rsym
,
"_"
);
strcat
(
rsym
+
1
,
sym
.
c_str
());
std
::
string
rsym
=
'_'
+
sym
;
NSSymbol
symbol
=
NSLookupSymbolInModule
(
lib
,
rsym
);
NSSymbol
symbol
=
NSLookupSymbolInModule
(
lib
,
rsym
.
c_str
()
);
if
(
symbol
)
{
result
=
NSAddressOfSymbol
(
symbol
);
}
delete
[]
rsym
;
// Hack to cast pointer-to-data to pointer-to-function.
return
*
reinterpret_cast
<
DynamicLoader
::
SymbolPointer
*>
(
&
result
);
}
...
...
@@ -237,17 +233,12 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
void
*
result
;
#if defined(__BORLANDC__) || defined(__WATCOMC__)
// Need to prepend symbols with '_'
size_t
len
=
sym
.
size
();
char
*
rsym
=
new
char
[
len
+
1
+
1
];
strcpy
(
rsym
,
"_"
);
strcat
(
rsym
,
sym
.
c_str
());
std
::
string
ssym
=
'_'
+
sym
;
const
char
*
rsym
=
ssym
.
c_str
();
#else
const
char
*
rsym
=
sym
.
c_str
();
#endif
result
=
(
void
*
)
GetProcAddress
(
lib
,
rsym
);
#if defined(__BORLANDC__) || defined(__WATCOMC__)
delete
[]
rsym
;
#endif
// Hack to cast pointer-to-data to pointer-to-function.
#ifdef __WATCOMC__
return
*
(
DynamicLoader
::
SymbolPointer
*
)(
&
result
);
...
...
This diff is collapsed.
Click to expand it.
Brad King
@brad.king
mentioned in commit
7890c0cc
·
7 years ago
mentioned in commit
7890c0cc
mentioned in commit 7890c0cc4c6f4c4ac4737a93ebaf4ba7ad982662
Toggle commit list
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