Exemplo n.º 1
0
/**
 * Creates a new s_dialog structure.
 * Does not add the structure to the list
 * @param call_id - call_id of the dialog
 * @param aor - aor of the user
 * @param dir - the direction
 * @returns the new s_dialog* or NULL s_dialog
 */
s_dialog* new_s_dialog(str call_id,str aor, enum s_dialog_direction dir)
{
	s_dialog *d;
	
	if (!s_dialog_count_increment()) return 0;
	d = shm_malloc(sizeof(s_dialog));
	if (!d) {
		LOG(L_ERR,"ERR:"M_NAME":new_s_dialog(): Unable to alloc %d bytes\n",
			sizeof(s_dialog));
		goto error;
	}
	memset(d,0,sizeof(s_dialog));
	
	d->hash = get_s_dialog_hash(call_id);		
	STR_SHM_DUP(d->call_id,call_id,"shm");
	STR_SHM_DUP(d->aor,aor,"shm");	
	d->direction = dir;
	d->is_releasing = 0;
	return d;
error:
out_of_memory:
	if (d){
		shm_free(d);		
	}
	s_dialog_count_decrement();
	return 0;
}
Exemplo n.º 2
0
/**
 * Frees a dialog.
 * @param d - the dialog to delete
 */
void free_s_dialog(s_dialog *d)
{
	if (!d) return;
	if (d->call_id.s) shm_free(d->call_id.s);
	if (d->aor.s) shm_free(d->aor.s);	
	if (d->method_str.s) shm_free(d->method_str.s);
	if (d->dialog_s) tmb.free_dlg(d->dialog_s);
	if (d->dialog_c) tmb.free_dlg(d->dialog_c);		
	shm_free(d);
	s_dialog_count_decrement(); 	
}