Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
KWSys
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
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
Simon Wilson
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
No related merge requests found
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.
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