Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Kirill Smelkov
mariadb
Commits
d24a78d1
Commit
d24a78d1
authored
Jul 26, 2012
by
Tor Didriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backport of Bug#14171740 65562: STRING::SHRINK SHOULD BE A NO-OP WHEN ALLOCED=0
parent
aef1982b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
client/sql_string.h
client/sql_string.h
+7
-3
sql/sql_string.h
sql/sql_string.h
+7
-3
No files found.
client/sql_string.h
View file @
d24a78d1
/*
Copyright (c) 2000, 201
0
, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -195,8 +195,12 @@ public:
}
bool
real_alloc
(
uint32
arg_length
);
// Empties old string
bool
realloc
(
uint32
arg_length
);
inline
void
shrink
(
uint32
arg_length
)
// Shrink buffer
// Shrink the buffer, but only if it is allocated on the heap.
inline
void
shrink
(
uint32
arg_length
)
{
if
(
!
is_alloced
())
return
;
if
(
arg_length
<
Alloced_length
)
{
char
*
new_ptr
;
...
...
@@ -212,7 +216,7 @@ public:
}
}
}
bool
is_alloced
()
{
return
alloced
;
}
bool
is_alloced
()
const
{
return
alloced
;
}
inline
String
&
operator
=
(
const
String
&
s
)
{
if
(
&
s
!=
this
)
...
...
sql/sql_string.h
View file @
d24a78d1
/*
Copyright (c) 2000, 201
1
, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2000, 201
2
, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
...
...
@@ -225,8 +225,12 @@ public:
}
bool
real_alloc
(
uint32
arg_length
);
// Empties old string
bool
realloc
(
uint32
arg_length
);
inline
void
shrink
(
uint32
arg_length
)
// Shrink buffer
// Shrink the buffer, but only if it is allocated on the heap.
inline
void
shrink
(
uint32
arg_length
)
{
if
(
!
is_alloced
())
return
;
if
(
arg_length
<
Alloced_length
)
{
char
*
new_ptr
;
...
...
@@ -242,7 +246,7 @@ public:
}
}
}
bool
is_alloced
()
{
return
alloced
;
}
bool
is_alloced
()
const
{
return
alloced
;
}
inline
String
&
operator
=
(
const
String
&
s
)
{
if
(
&
s
!=
this
)
...
...
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