MCPcopy Create free account
hub / github.com/MariaDB/server / cleanup_variables

Function cleanup_variables

sql/sql_plugin.cc:3362–3396  ·  view source on GitHub ↗

Frees memory used by system variables Unlike plugin_vars_free_values() it frees all variables of all plugins, it's used on shutdown. */

Source from the content-addressed store, hash-verified

3360 it's used on shutdown.
3361*/
3362static void cleanup_variables(struct system_variables *vars)
3363{
3364 st_bookmark *v;
3365 uint idx;
3366
3367 mysql_prlock_rdlock(&LOCK_system_variables_hash);
3368 for (idx= 0; idx < bookmark_hash.records; idx++)
3369 {
3370 v= (st_bookmark*) my_hash_element(&bookmark_hash, idx);
3371
3372 if (v->version > vars->dynamic_variables_version)
3373 continue; /* not in vars */
3374
3375 DBUG_ASSERT((uint)v->offset <= vars->dynamic_variables_head);
3376
3377 /* free allocated strings (PLUGIN_VAR_STR | PLUGIN_VAR_MEMALLOC) */
3378 if ((v->key[0] & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_STR &&
3379 v->key[0] & BOOKMARK_MEMALLOC)
3380 {
3381 char **ptr= (char**)(vars->dynamic_variables_ptr + v->offset);
3382 my_free(*ptr);
3383 *ptr= NULL;
3384 }
3385 }
3386 mysql_prlock_unlock(&LOCK_system_variables_hash);
3387
3388 DBUG_ASSERT(vars->table_plugin == NULL);
3389 DBUG_ASSERT(vars->tmp_table_plugin == NULL);
3390 DBUG_ASSERT(vars->enforced_table_plugin == NULL);
3391
3392 my_free(vars->dynamic_variables_ptr);
3393 vars->dynamic_variables_ptr= NULL;
3394 vars->dynamic_variables_size= 0;
3395 vars->dynamic_variables_version= 0;
3396}
3397
3398
3399void plugin_thdvar_cleanup(THD *thd)

Callers 3

plugin_shutdownFunction · 0.85
plugin_thdvar_initFunction · 0.85
plugin_thdvar_cleanupFunction · 0.85

Calls 2

my_hash_elementFunction · 0.85
my_freeFunction · 0.85

Tested by

no test coverage detected