Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b8938419
Commit
b8938419
authored
Jun 14, 2010
by
Sergei Golubchik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysqltest: use setenv, not putenv, to make gcov happy.
(backport from MySQL)
parent
8cf2640e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
13 deletions
+31
-13
client/mysqltest.cc
client/mysqltest.cc
+31
-13
No files found.
client/mysqltest.cc
View file @
b8938419
...
...
@@ -73,6 +73,10 @@
#define QUERY_SEND_FLAG 1
#define QUERY_REAP_FLAG 2
#ifndef HAVE_SETENV
static
int
setenv
(
const
char
*
name
,
const
char
*
value
,
int
overwrite
);
#endif
enum
{
OPT_SKIP_SAFEMALLOC
=
OPT_MAX_CLIENT_OPTION
,
OPT_PS_PROTOCOL
,
OPT_SP_PROTOCOL
,
OPT_CURSOR_PROTOCOL
,
OPT_VIEW_PROTOCOL
,
...
...
@@ -226,7 +230,6 @@ typedef struct
int
alloced_len
;
int
int_dirty
;
/* do not update string if int is updated until first read */
int
alloced
;
char
*
env_s
;
}
VAR
;
/*Perl/shell-like variable registers */
...
...
@@ -1981,13 +1984,20 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
+
name_len
+
1
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
tmp_var
->
name
=
(
name
)
?
(
char
*
)
tmp_var
+
sizeof
(
*
tmp_var
)
:
0
;
if
(
name
!=
NULL
)
{
tmp_var
->
name
=
reinterpret_cast
<
char
*>
(
tmp_var
)
+
sizeof
(
*
tmp_var
);
memcpy
(
tmp_var
->
name
,
name
,
name_len
);
tmp_var
->
name
[
name_len
]
=
0
;
}
else
tmp_var
->
name
=
NULL
;
tmp_var
->
alloced
=
(
v
==
0
);
if
(
!
(
tmp_var
->
str_val
=
(
char
*
)
my_malloc
(
val_alloc_len
+
1
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
memcpy
(
tmp_var
->
name
,
name
,
name_len
);
if
(
val
)
{
memcpy
(
tmp_var
->
str_val
,
val
,
val_len
);
...
...
@@ -1998,7 +2008,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
tmp_var
->
alloced_len
=
val_alloc_len
;
tmp_var
->
int_val
=
(
val
)
?
atoi
(
val
)
:
0
;
tmp_var
->
int_dirty
=
0
;
tmp_var
->
env_s
=
0
;
return
tmp_var
;
}
...
...
@@ -2006,7 +2015,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
void
var_free
(
void
*
v
)
{
my_free
(((
VAR
*
)
v
)
->
str_val
,
MYF
(
MY_WME
));
my_free
(((
VAR
*
)
v
)
->
env_s
,
MYF
(
MY_ALLOW_ZERO_PTR
));
if
(((
VAR
*
)
v
)
->
alloced
)
my_free
(
v
,
MYF
(
MY_WME
));
}
...
...
@@ -2127,20 +2135,15 @@ void var_set(const char *var_name, const char *var_name_end,
if
(
env_var
)
{
char
buf
[
1024
],
*
old_env_s
=
v
->
env_s
;
if
(
v
->
int_dirty
)
{
sprintf
(
v
->
str_val
,
"%d"
,
v
->
int_val
);
v
->
int_dirty
=
0
;
v
->
str_val_len
=
strlen
(
v
->
str_val
);
}
my_snprintf
(
buf
,
sizeof
(
buf
),
"%.*s=%.*s"
,
v
->
name_len
,
v
->
name
,
v
->
str_val_len
,
v
->
str_val
);
if
(
!
(
v
->
env_s
=
my_strdup
(
buf
,
MYF
(
MY_WME
))))
die
(
"Out of memory"
);
putenv
(
v
->
env_s
);
my_free
(
old_env_s
,
MYF
(
MY_ALLOW_ZERO_PTR
));
/* setenv() expects \0-terminated strings */
DBUG_ASSERT
(
v
->
name
[
v
->
name_len
]
==
0
);
setenv
(
v
->
name
,
v
->
str_val
,
1
);
}
DBUG_VOID_RETURN
;
}
...
...
@@ -9829,3 +9832,18 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input)
delete_dynamic
(
&
lines
);
DBUG_VOID_RETURN
;
}
#ifndef HAVE_SETENV
static
int
setenv
(
const
char
*
name
,
const
char
*
value
,
int
overwrite
)
{
size_t
buflen
=
strlen
(
name
)
+
strlen
(
value
)
+
2
;
char
*
envvar
=
(
char
*
)
malloc
(
buflen
);
if
(
!
envvar
)
return
ENOMEM
;
strcpy
(
envvar
,
name
);
strcat
(
envvar
,
"="
);
strcat
(
envvar
,
value
);
putenv
(
envvar
);
return
0
;
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment