AST_LIST_UNLOCK(&be_list);
}
-static struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)
+static struct ast_cdr *cdr_dup(struct ast_cdr *cdr)
{
- struct ast_cdr *newcdr = NULL;
+ struct ast_cdr *newcdr;
if (!(newcdr = ast_cdr_alloc())) {
ast_log(LOG_ERROR, "Memory Error!\n");
- } else {
- memcpy(newcdr,cdr,sizeof(struct ast_cdr));
- /* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
- memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
- ast_cdr_copy_vars(newcdr, cdr);
+ return NULL;
}
+ memcpy(newcdr, cdr, sizeof(*newcdr));
+ /* The varshead is unusable, volatile even, after the memcpy so we take care of that here */
+ memset(&newcdr->varshead, 0, sizeof(newcdr->varshead));
+ ast_cdr_copy_vars(newcdr, cdr);
+
return newcdr;
}
if (ast_test_flag(&tmp, AST_CDR_FLAG_LOCKED) || !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
if (ast_test_flag(&tmp, AST_CDR_FLAG_POSTED)) {
ast_cdr_end(cdr);
- if ((dup = ast_cdr_dup(cdr))) {
+ if ((dup = cdr_dup(cdr))) {
ast_cdr_detach(dup);
}
ast_set_flag(cdr, AST_CDR_FLAG_POSTED);