~ubuntu-branches/ubuntu/hardy/mysql-dfsg-5.0/hardy-updates

« back to all changes in this revision

Viewing changes to mysys/typelib.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2007-04-02 16:10:53 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20070402161053-zkil9hjq9k5p1uzv
Tags: 5.0.37-0ubuntu1
* New upstream bugfix release.
  - Fixes replication failure with auto-increment and on duplicate key
    update, a regression introduced into 5.0.24. (LP: #95821)
* debian/control: Set Ubuntu maintainer.
* debian/rules: Change comments from 'Debian etch' to 'Ubuntu 7.04'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   This program is free software; you can redistribute it and/or modify
4
4
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; either version 2 of the License, or
6
 
   (at your option) any later version.
 
5
   the Free Software Foundation; version 2 of the License.
7
6
 
8
7
   This program is distributed in the hope that it will be useful,
9
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
119
118
    return(typelib->type_names[nr]);
120
119
  return "?";
121
120
}
 
121
 
 
122
 
 
123
/*
 
124
  Create a copy of a specified TYPELIB structure.
 
125
 
 
126
  SYNOPSIS
 
127
    copy_typelib()
 
128
    root        pointer to a MEM_ROOT object for allocations
 
129
    from        pointer to a source TYPELIB structure
 
130
 
 
131
  RETURN
 
132
    pointer to the new TYPELIB structure on successful copy, or
 
133
    NULL otherwise
 
134
*/
 
135
 
 
136
TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from)
 
137
{
 
138
  TYPELIB *to;
 
139
  uint i;
 
140
 
 
141
  if (!from)
 
142
    return NULL;
 
143
 
 
144
  if (!(to= (TYPELIB*) alloc_root(root, sizeof(TYPELIB))))
 
145
    return NULL;
 
146
 
 
147
  if (!(to->type_names= (const char **)
 
148
        alloc_root(root, (sizeof(char *) + sizeof(int)) * (from->count + 1))))
 
149
    return NULL;
 
150
  to->type_lengths= (unsigned int *)(to->type_names + from->count + 1);
 
151
  to->count= from->count;
 
152
  if (from->name)
 
153
  {
 
154
    if (!(to->name= strdup_root(root, from->name)))
 
155
      return NULL;
 
156
  }
 
157
  else
 
158
    to->name= NULL;
 
159
 
 
160
  for (i= 0; i < from->count; i++)
 
161
  {
 
162
    if (!(to->type_names[i]= strmake_root(root, from->type_names[i],
 
163
                                          from->type_lengths[i])))
 
164
      return NULL;
 
165
    to->type_lengths[i]= from->type_lengths[i];
 
166
  }
 
167
  to->type_names[to->count]= NULL;
 
168
  to->type_lengths[to->count]= 0;
 
169
 
 
170
  return to;
 
171
}