@@ -282,31 +282,14 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
282
282
283
283
DBG_INF ("Freeing memory of members" );
284
284
285
- if (conn -> hostname .s ) {
286
- mnd_pefree (conn -> hostname .s , pers );
287
- conn -> hostname .s = NULL ;
288
- }
289
- if (conn -> username .s ) {
290
- mnd_pefree (conn -> username .s , pers );
291
- conn -> username .s = NULL ;
292
- }
293
- if (conn -> password .s ) {
294
- mnd_pefree (conn -> password .s , pers );
295
- conn -> password .s = NULL ;
296
- }
297
- if (conn -> connect_or_select_db .s ) {
298
- mnd_pefree (conn -> connect_or_select_db .s , pers );
299
- conn -> connect_or_select_db .s = NULL ;
300
- }
301
- if (conn -> unix_socket .s ) {
302
- mnd_pefree (conn -> unix_socket .s , pers );
303
- conn -> unix_socket .s = NULL ;
304
- }
285
+ mysqlnd_set_persistent_string (& conn -> hostname , NULL , 0 , pers );
286
+ mysqlnd_set_persistent_string (& conn -> username , NULL , 0 , pers );
287
+ mysqlnd_set_persistent_string (& conn -> password , NULL , 0 , pers );
288
+ mysqlnd_set_persistent_string (& conn -> connect_or_select_db , NULL , 0 , pers );
289
+ mysqlnd_set_persistent_string (& conn -> unix_socket , NULL , 0 , pers );
305
290
DBG_INF_FMT ("scheme=%s" , conn -> scheme .s );
306
- if (conn -> scheme .s ) {
307
- mnd_pefree (conn -> scheme .s , pers );
308
- conn -> scheme .s = NULL ;
309
- }
291
+ mysqlnd_set_persistent_string (& conn -> scheme , NULL , 0 , pers );
292
+
310
293
if (conn -> server_version ) {
311
294
mnd_pefree (conn -> server_version , pers );
312
295
conn -> server_version = NULL ;
@@ -315,14 +298,8 @@ MYSQLND_METHOD(mysqlnd_conn_data, free_contents)(MYSQLND_CONN_DATA * conn)
315
298
mnd_pefree (conn -> host_info , pers );
316
299
conn -> host_info = NULL ;
317
300
}
318
- if (conn -> authentication_plugin_data .s ) {
319
- mnd_pefree (conn -> authentication_plugin_data .s , pers );
320
- conn -> authentication_plugin_data .s = NULL ;
321
- }
322
- if (conn -> last_message .s ) {
323
- mnd_efree (conn -> last_message .s );
324
- conn -> last_message .s = NULL ;
325
- }
301
+ mysqlnd_set_persistent_string (& conn -> authentication_plugin_data , NULL , 0 , pers );
302
+ mysqlnd_set_string (& conn -> last_message , NULL , 0 );
326
303
327
304
conn -> charset = NULL ;
328
305
conn -> greet_charset = NULL ;
@@ -406,10 +383,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, end_psession)(MYSQLND_CONN_DATA * conn)
406
383
conn -> current_result -> m .free_result (conn -> current_result , TRUE);
407
384
conn -> current_result = NULL ;
408
385
}
409
- if (conn -> last_message .s ) {
410
- mnd_efree (conn -> last_message .s );
411
- conn -> last_message .s = NULL ;
412
- }
386
+ mysqlnd_set_string (& conn -> last_message , NULL , 0 );
413
387
conn -> error_info = & conn -> error_info_impl ;
414
388
DBG_RETURN (PASS );
415
389
}
@@ -681,8 +655,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
681
655
pfc -> data -> compressed = mysql_flags & CLIENT_COMPRESS ? TRUE:FALSE;
682
656
683
657
684
- conn -> scheme .s = mnd_pestrndup (transport .s , transport .l , conn -> persistent );
685
- conn -> scheme .l = transport .l ;
658
+ mysqlnd_set_persistent_string (& conn -> scheme , transport .s , transport .l , conn -> persistent );
686
659
if (transport .s ) {
687
660
mnd_sprintf_free (transport .s );
688
661
transport .s = NULL ;
@@ -692,17 +665,13 @@ MYSQLND_METHOD(mysqlnd_conn_data, connect)(MYSQLND_CONN_DATA * conn,
692
665
goto err ; /* OOM */
693
666
}
694
667
695
- conn -> username .l = username .l ;
696
- conn -> username .s = mnd_pestrndup (username .s , conn -> username .l , conn -> persistent );
697
- conn -> password .l = password .l ;
698
- conn -> password .s = mnd_pestrndup (password .s , conn -> password .l , conn -> persistent );
668
+ mysqlnd_set_persistent_string (& conn -> username , username .s , username .l , conn -> persistent );
669
+ mysqlnd_set_persistent_string (& conn -> password , username .s , password .l , conn -> persistent );
699
670
conn -> port = port ;
700
- conn -> connect_or_select_db .l = database .l ;
701
- conn -> connect_or_select_db .s = mnd_pestrndup (database .s , conn -> connect_or_select_db .l , conn -> persistent );
671
+ mysqlnd_set_persistent_string (& conn -> connect_or_select_db , database .s , database .l , conn -> persistent );
702
672
703
673
if (!unix_socket && !named_pipe ) {
704
- conn -> hostname .s = mnd_pestrndup (hostname .s , hostname .l , conn -> persistent );
705
- conn -> hostname .l = hostname .l ;
674
+ mysqlnd_set_persistent_string (& conn -> hostname , hostname .s , hostname .l , conn -> persistent );
706
675
{
707
676
char * p ;
708
677
mnd_sprintf (& p , 0 , "%s via TCP/IP" , conn -> hostname .s );
0 commit comments