What is the purpose of brackets {}
in C code without the usage of
control structures like loops, if-else, function calls etc. ?
An example can be this:
// Add UDP transport.
{
// Init transport config structure
pjsua_transport_config cfg;
pjsua_transport_config_default(&cfg);
cfg.port = 5080;
// Add TCP transport.
status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
if (status != PJ_SUCCESS) error_exit("Error creating transport", status);
}
Is this just to show that this is a way to split your code into semantic blocks during a long function? And if so, wouldn't it be cleaner to make this into an own function?
The code can be found in this blog: Xianwen's blog