1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Backport of Bug#14171740 65562: STRING::SHRINK SHOULD BE A NO-OP WHEN ALLOCED=0

This commit is contained in:
Tor Didriksen
2012-07-26 15:05:24 +02:00
parent 3b954d1ddd
commit 76386edb83
2 changed files with 14 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2000, 2012, 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)