else
command_print(CMD, "copy failed");
- if (data != NULL)
- free(data);
+ free(data);
if (f != NULL)
fclose(f);
param = (struct chibios_params *) rtos->rtos_specific_params;
/* Free existing memory description.*/
- if (param->signature) {
- free(param->signature);
- param->signature = 0;
- }
+ free(param->signature);
+ param->signature = NULL;
signature = malloc(sizeof(*signature));
if (!signature) {
task_list = (*t)->next;
/* free content of threads */
- if ((*t)->context)
- free((*t)->context);
+ free((*t)->context);
free(*t);
*t = prev ? prev : task_list;
while (temp != NULL) {
old = temp;
- if (temp->context)
- free(temp->context);
+ free(temp->context);
temp = temp->next;
free(old);
while (thread_list != NULL) {
thread_list->status = 0; /*setting all tasks to dead state*/
- if (thread_list->context) {
- free(thread_list->context);
- thread_list->context = NULL;
- }
+ free(thread_list->context);
+ thread_list->context = NULL;
thread_list = thread_list->next;
}
if (!target->rtos)
return;
- if (target->rtos->symbols)
- free(target->rtos->symbols);
-
+ free(target->rtos->symbols);
free(target->rtos);
target->rtos = NULL;
}
return 0;
os->type = *type;
- if (os->symbols) {
- free(os->symbols);
- os->symbols = NULL;
- }
+
+ free(os->symbols);
+ os->symbols = NULL;
return 1;
}
/* if this connection registered a debug-message receiver delete it */
delete_debug_msg_receiver(connection->cmd_ctx, target);
- if (connection->priv) {
- free(connection->priv);
- connection->priv = NULL;
- } else
- LOG_ERROR("BUG: connection->priv == NULL");
+ free(connection->priv);
+ connection->priv = NULL;
target_unregister_event_callback(gdb_target_callback_event_handler, connection);
char *t = *xml;
*xml = realloc(*xml, *size);
if (*xml == NULL) {
- if (t)
- free(t);
+ free(t);
*retval = ERROR_SERVER_REMOTE_CLOSED;
return;
}
remove_connections(c);
- if (c->name)
- free(c->name);
+ free(c->name);
if (c->type == CONNECTION_PIPE) {
if (c->fd != -1)
close(c->fd);
}
- if (c->port)
- free(c->port);
-
- if (c->priv)
- free(c->priv);
-
+ free(c->port);
+ free(c->priv);
/* delete service */
free(c);
if (*t_con->line && (prev_line == NULL ||
strcmp(t_con->line, prev_line))) {
/* if the history slot is already taken, free it */
- if (t_con->history[t_con->next_history])
- free(t_con->history[t_con->next_history]);
+ free(t_con->history[t_con->next_history]);
/* add line to history */
t_con->history[t_con->next_history] = strdup(t_con->line);
t_con->current_history =
t_con->next_history;
- if (t_con->history[t_con->current_history])
- free(t_con->history[t_con->current_history]);
+ free(t_con->history[t_con->current_history]);
t_con->history[t_con->current_history] = strdup("");
}
log_remove_callback(telnet_log_callback, connection);
- if (t_con->prompt) {
- free(t_con->prompt);
- t_con->prompt = NULL;
- }
+ free(t_con->prompt);
+ t_con->prompt = NULL;
/* save telnet history */
telnet_save_history(t_con);
for (i = 0; i < TELNET_LINE_HISTORY_SIZE; i++) {
- if (t_con->history[i]) {
- free(t_con->history[i]);
- t_con->history[i] = NULL;
- }
+ free(t_con->history[i]);
+ t_con->history[i] = NULL;
}
/* if this connection registered a debug-message receiver delete it */
delete_debug_msg_receiver(connection->cmd_ctx, NULL);
- if (connection->priv) {
- free(connection->priv);
- connection->priv = NULL;
- } else
- LOG_ERROR("BUG: connection->priv == NULL");
+ free(connection->priv);
+ connection->priv = NULL;
return ERROR_OK;
}
static void svf_free_xxd_para(struct svf_xxr_para *para)
{
if (NULL != para) {
- if (para->tdi != NULL) {
- free(para->tdi);
- para->tdi = NULL;
- }
- if (para->tdo != NULL) {
- free(para->tdo);
- para->tdo = NULL;
- }
- if (para->mask != NULL) {
- free(para->mask);
- para->mask = NULL;
- }
- if (para->smask != NULL) {
- free(para->smask);
- para->smask = NULL;
- }
+ free(para->tdi);
+ para->tdi = NULL;
+
+ free(para->tdo);
+ para->tdo = NULL;
+
+ free(para->mask);
+ para->mask = NULL;
+
+ free(para->smask);
+ para->smask = NULL;
}
}
svf_fd = 0;
/* free buffers */
- if (svf_command_buffer) {
- free(svf_command_buffer);
- svf_command_buffer = NULL;
- svf_command_buffer_size = 0;
- }
- if (svf_check_tdo_para) {
- free(svf_check_tdo_para);
- svf_check_tdo_para = NULL;
- svf_check_tdo_para_index = 0;
- }
- if (svf_tdi_buffer) {
- free(svf_tdi_buffer);
- svf_tdi_buffer = NULL;
- }
- if (svf_tdo_buffer) {
- free(svf_tdo_buffer);
- svf_tdo_buffer = NULL;
- }
- if (svf_mask_buffer) {
- free(svf_mask_buffer);
- svf_mask_buffer = NULL;
- }
+ free(svf_command_buffer);
+ svf_command_buffer = NULL;
+ svf_command_buffer_size = 0;
+
+ free(svf_check_tdo_para);
+ svf_check_tdo_para = NULL;
+ svf_check_tdo_para_index = 0;
+
+ free(svf_tdi_buffer);
+ svf_tdi_buffer = NULL;
+
+ free(svf_tdo_buffer);
+ svf_tdo_buffer = NULL;
+
+ free(svf_mask_buffer);
+ svf_mask_buffer = NULL;
+
svf_buffer_index = 0;
svf_buffer_size = 0;
int new_byte_len = (new_bit_len + 7) >> 3;
if ((NULL == *arr) || (((orig_bit_len + 7) >> 3) < ((new_bit_len + 7) >> 3))) {
- if (*arr != NULL) {
- free(*arr);
- *arr = NULL;
- }
- *arr = malloc(new_byte_len);
+ free(*arr);
+ *arr = calloc(1, new_byte_len);
if (NULL == *arr) {
LOG_ERROR("not enough memory");
return ERROR_FAIL;
}
- memset(*arr, 0, new_byte_len);
}
return ERROR_OK;
}
xsdrsize = be_to_h_u32(xsdrsize_buf);
LOG_DEBUG("XSDRSIZE %d", xsdrsize);
- if (dr_out_buf)
- free(dr_out_buf);
- if (dr_in_buf)
- free(dr_in_buf);
- if (dr_in_mask)
- free(dr_in_mask);
+ free(dr_out_buf);
+ free(dr_in_buf);
+ free(dr_in_mask);
dr_out_buf = malloc((xsdrsize + 7) / 8);
dr_in_buf = malloc((xsdrsize + 7) / 8);
return ERROR_FAIL;
}
- if (dr_out_buf)
- free(dr_out_buf);
-
- if (dr_in_buf)
- free(dr_in_buf);
-
- if (dr_in_mask)
- free(dr_in_mask);
+ free(dr_out_buf);
+ free(dr_in_buf);
+ free(dr_in_mask);
close(xsvf_fd);