diff options
author | unknown <kaa@polly.local> | 2006-12-14 21:24:52 +0300 |
---|---|---|
committer | unknown <kaa@polly.local> | 2006-12-14 21:24:52 +0300 |
commit | db1a2d2d802320a6c40a4f468651895c5ea369da (patch) | |
tree | 2c7af9c9d9f27b2eadc1547ead8f6d2b476eddb9 /mysys/typelib.c | |
parent | 931dcc8a8328698397e7bd194eb1a7041e0d1970 (diff) | |
parent | 5b71281467c85dc705da30f0fe4ebc094f0ff983 (diff) | |
download | mariadb-git-db1a2d2d802320a6c40a4f468651895c5ea369da.tar.gz |
Merge polly.local:/tmp/maint/bug24117/my50-bug24117
into polly.local:/home/kaa/src/maint/mysql-5.0-maint
mysys/typelib.c:
Auto merged
sql/field.cc:
Auto merged
sql/field.h:
Auto merged
Diffstat (limited to 'mysys/typelib.c')
-rw-r--r-- | mysys/typelib.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mysys/typelib.c b/mysys/typelib.c index d329b687668..8906b702aa8 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -119,3 +119,54 @@ const char *get_type(TYPELIB *typelib, uint nr) return(typelib->type_names[nr]); return "?"; } + + +/* + Create a copy of a specified TYPELIB structure. + + SYNOPSIS + copy_typelib() + root pointer to a MEM_ROOT object for allocations + from pointer to a source TYPELIB structure + + RETURN + pointer to the new TYPELIB structure on successful copy, or + NULL otherwise +*/ + +TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from) +{ + TYPELIB *to; + uint i; + + if (!from) + return NULL; + + if (!(to= (TYPELIB*) alloc_root(root, sizeof(TYPELIB)))) + return NULL; + + if (!(to->type_names= (const char **) + alloc_root(root, (sizeof(char *) + sizeof(int)) * (from->count + 1)))) + return NULL; + to->type_lengths= (unsigned int *)(to->type_names + from->count + 1); + to->count= from->count; + if (from->name) + { + if (!(to->name= strdup_root(root, from->name))) + return NULL; + } + else + to->name= NULL; + + for (i= 0; i < from->count; i++) + { + if (!(to->type_names[i]= strmake_root(root, from->type_names[i], + from->type_lengths[i]))) + return NULL; + to->type_lengths[i]= from->type_lengths[i]; + } + to->type_names[to->count]= NULL; + to->type_lengths[to->count]= 0; + + return to; +} |