~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/heap/hp_rename.c

  • Committer: Monty Taylor
  • Date: 2008-12-18 07:24:54 UTC
  • mto: This revision was merged to the branch mainline in revision 714.
  • Revision ID: monty@bitters-20081218072454-8pnep622damjgqli
Fixed one more my_time thing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  Rename a table
18
18
*/
19
19
 
20
 
#include "heap_priv.h"
 
20
#include "heapdef.h"
21
21
#include <string.h>
22
 
#include <cstdlib>
23
22
 
24
23
int heap_rename(const char *old_name, const char *new_name)
25
24
{
26
 
  HP_SHARE *info;
 
25
  register HP_SHARE *info;
 
26
  char *name_buff;
27
27
 
28
 
  THR_LOCK_heap.lock();
 
28
  pthread_mutex_lock(&THR_LOCK_heap);
29
29
  if ((info = hp_find_named_heap(old_name)))
30
30
  {
31
 
    info->name.clear();
32
 
    info->name.append(new_name);
 
31
    if (!(name_buff=(char*) strdup(new_name)))
 
32
    {
 
33
      pthread_mutex_unlock(&THR_LOCK_heap);
 
34
      return(my_errno);
 
35
    }
 
36
    free(info->name);
 
37
    info->name=name_buff;
33
38
  }
34
 
  THR_LOCK_heap.unlock();
 
39
  pthread_mutex_unlock(&THR_LOCK_heap);
35
40
  return(0);
36
41
}