Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
416
Issues
416
List
Boards
Labels
Service Desk
Milestones
Merge Requests
67
Merge Requests
67
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
ISC Open Source Projects
Kea
Commits
fb185ed8
Commit
fb185ed8
authored
Nov 09, 2012
by
Stephen Morris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2342] Added comments as result of review
parent
bdb8039c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
2 deletions
+18
-2
src/lib/dhcp/mysql_lease_mgr.cc
src/lib/dhcp/mysql_lease_mgr.cc
+18
-2
No files found.
src/lib/dhcp/mysql_lease_mgr.cc
View file @
fb185ed8
...
...
@@ -150,9 +150,17 @@ public:
// In the following statement, the string is being read. However, the
// MySQL C interface does not use "const", so the "buffer" element
// is declared as "char*" instead of "const char*". To resolve this,
// the "const" is discarded. Note that the address of addr6_.c_str()
// the "const" is discarded.
(
Note that the address of addr6_.c_str()
// is guaranteed to be valid until the next non-const operation on
// addr6_.
// addr6_.)
//
// Note that the const_cast could be avoided by copying the string to
// a writeable buffer and storing the address of that in the "buffer"
// element. However, this introduces a copy operation (with additional
// overhead) purely to get round the strictures introduced by design of
// the MySQL interface (which uses the area pointed to by "buffer" as
// input when specifying query parameters and as output when retrieving
// data). For that reason, "const_cast" has been used.
bind_
[
0
].
buffer_type
=
MYSQL_TYPE_STRING
;
bind_
[
0
].
buffer
=
const_cast
<
char
*>
(
addr6_
.
c_str
());
bind_
[
0
].
buffer_length
=
addr6_length_
;
...
...
@@ -821,6 +829,14 @@ MySqlLeaseMgr::getLease6(const DUID& duid, uint32_t iaid) const {
// MySQL C interface does not use "const", so the "buffer" element
// is declared as "char*" instead of "const char*". To resolve this,
// the "const" is discarded before the uint8_t* is cast to char*.
//
// Note that the const_cast could be avoided by copying the DUID to
// a writeable buffer and storing the address of that in the "buffer"
// element. However, this introduces a copy operation (with additional
// overhead) purely to get round the strictures introduced by design of
// the MySQL interface (which uses the area pointed to by "buffer" as
// input when specifying query parameters and as output when retrieving
// data). For that reason, "const_cast" has been used.
const
vector
<
uint8_t
>&
duid_vector
=
duid
.
getDuid
();
unsigned
long
duid_length
=
duid_vector
.
size
();
inbind
[
0
].
buffer_type
=
MYSQL_TYPE_BLOB
;
...
...
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