1 /*****************************************************************************
2
3 Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved.
4 Copyright (c) 2019, MariaDB Corporation.
5
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free Software
8 Foundation; version 2 of the License.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License along with
15 this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
17
18 *****************************************************************************/
19
20 /********************************************************************//**
21 @file ut/ut0mem.cc
22 Memory primitives
23
24 Created 5/11/1994 Heikki Tuuri
25 *************************************************************************/
26
27 #include "ut0mem.h"
28
29 /********************************************************************
30 Concatenate 3 strings.*/
31 char*
ut_str3cat(const char * s1,const char * s2,const char * s3)32 ut_str3cat(
33 /*=======*/
34 /* out, own: concatenated string, must be
35 freed with ut_free() */
36 const char* s1, /* in: string 1 */
37 const char* s2, /* in: string 2 */
38 const char* s3) /* in: string 3 */
39 {
40 char* s;
41 ulint s1_len = strlen(s1);
42 ulint s2_len = strlen(s2);
43 ulint s3_len = strlen(s3);
44
45 s = static_cast<char*>(ut_malloc_nokey(s1_len + s2_len + s3_len + 1));
46
47 memcpy(s, s1, s1_len);
48 memcpy(s + s1_len, s2, s2_len);
49 memcpy(s + s1_len + s2_len, s3, s3_len);
50
51 s[s1_len + s2_len + s3_len] = '\0';
52
53 return(s);
54 }
55