[asterisk-commits] mmichelson: branch group/issue8824 r183477 - in /team/group/issue8824: includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 19 16:48:42 CDT 2009


Author: mmichelson
Date: Thu Mar 19 16:48:39 2009
New Revision: 183477

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=183477
Log:
Address more comments in Russell's review.


Modified:
    team/group/issue8824/include/asterisk/callerid.h
    team/group/issue8824/main/callerid.c
    team/group/issue8824/main/channel.c
    team/group/issue8824/main/features.c

Modified: team/group/issue8824/include/asterisk/callerid.h
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/include/asterisk/callerid.h?view=diff&rev=183477&r1=183476&r2=183477
==============================================================================
--- team/group/issue8824/include/asterisk/callerid.h (original)
+++ team/group/issue8824/include/asterisk/callerid.h Thu Mar 19 16:48:39 2009
@@ -198,6 +198,11 @@
  * \param instr buffer of callerid stream (in audio form) to be parsed. Warning, data in buffer is changed.
  * \param name address of a pointer-to-char for the name value of the stream.
  * \param location address of a pointer-to-char for the phone number value of the stream.
+ * \note XXX 'name' is not parsed consistently e.g. we have
+ * input                   location        name
+ * " foo bar " <123>       123             ' foo bar ' (with spaces around)
+ * " foo bar "             NULL            'foo bar' (without spaces around)
+ * The parsing of leading and trailing space/quotes should be more consistent.
  * \return Returns 0 on success, -1 on failure.
  */
 int ast_callerid_parse(char *instr, char **name, char **location);

Modified: team/group/issue8824/main/callerid.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/main/callerid.c?view=diff&rev=183477&r1=183476&r2=183477
==============================================================================
--- team/group/issue8824/main/callerid.c (original)
+++ team/group/issue8824/main/callerid.c Thu Mar 19 16:48:39 2009
@@ -979,37 +979,16 @@
 	return 1;
 }
 
-/*!
- * \brief checks if string consists only of digits and * \# and +
- * \retval 1 if string is valid AST phone number
- * \retval 0 if not
-*/
 int ast_isphonenumber(const char *n)
 {
 	return ast_is_valid_string(n, "0123456789*#+");
 }
 
-/*!
- * \brief checks if string consists only of digits and ( ) - * \# and +
- * \details
- * Pre-qualifies the string for ast_shrink_phone_number()
- * \retval 1 if string is valid AST shrinkable phone number
- * \retval 0 if not
-*/
 int ast_is_shrinkable_phonenumber(const char *exten)
 {
 	return ast_is_valid_string(exten, "0123456789*#+()-.");
 }
 
-/*!
- * \brief Destructively parse instr for caller id information 
- * \return always returns 0, as the code always returns something.
- * \note XXX 'name' is not parsed consistently e.g. we have
- * input                   location        name
- * " foo bar " <123>       123             ' foo bar ' (with spaces around)
- * " foo bar "             NULL            'foo bar' (without spaces around)
- * The parsing of leading and trailing space/quotes should be more consistent.
- */
 int ast_callerid_parse(char *instr, char **name, char **location)
 {
 	char *ns, *ne, *ls, *le;

Modified: team/group/issue8824/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/main/channel.c?view=diff&rev=183477&r1=183476&r2=183477
==============================================================================
--- team/group/issue8824/main/channel.c (original)
+++ team/group/issue8824/main/channel.c Thu Mar 19 16:48:39 2009
@@ -794,6 +794,13 @@
 		return NULL;
 	}
 
+	if (!(tmp->cid.cid_name = ast_strdup(cid_name)) || !(tmp->cid.cid_num = ast_strdup(cid_num))) {
+		ast_string_field_free_memory(tmp);
+		sched_context_destroy(tmp->sched);
+		ast_free(tmp);
+		return NULL;
+	}
+
 #ifdef HAVE_EPOLL
 	tmp->epfd = epoll_create(25);
 #endif
@@ -862,9 +869,6 @@
 		ast_string_field_build(tmp, uniqueid, "%s-%li.%d", ast_config_AST_SYSTEM_NAME, 
 				       (long) time(NULL), ast_atomic_fetchadd_int(&uniqueint, 1));
 	}
-
-	tmp->cid.cid_name = ast_strdup(cid_name);
-	tmp->cid.cid_num = ast_strdup(cid_num);
 	
 	if (!ast_strlen_zero(name_fmt)) {
 		/* Almost every channel is calling this function, and setting the name via the ast_string_field_build() call.

Modified: team/group/issue8824/main/features.c
URL: http://svn.digium.com/svn-view/asterisk/team/group/issue8824/main/features.c?view=diff&rev=183477&r1=183476&r2=183477
==============================================================================
--- team/group/issue8824/main/features.c (original)
+++ team/group/issue8824/main/features.c Thu Mar 19 16:48:39 2009
@@ -1579,15 +1579,12 @@
 		 */
 		connected_line.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		ast_connected_line_update(xferchan, &connected_line);
-		/* We need to free the allocated information in connected_line before overwriting
-		 * the info with the callerid of xferchan. Otherwise, there would be a memory leak
-		 */
-		ast_party_connected_line_free(&connected_line);
 		ast_channel_lock(xferchan);
-		ast_party_connected_line_collect_caller(&connected_line, &xferchan->cid);
+		ast_copy_caller_to_connected(&connected_line, &xferchan->cid);
 		ast_channel_unlock(xferchan);
 		connected_line.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		ast_connected_line_update(newchan, &connected_line);
+		ast_party_connected_line_free(&connected_line);
 
 		if (ast_stream_and_wait(newchan, xfersound, ""))
 			ast_log(LOG_WARNING, "Failed to play transfer sound!\n");
@@ -1691,15 +1688,17 @@
 		}
 
 		ast_channel_lock(newchan);
-		ast_party_connected_line_collect_caller(&connected_line, &newchan->cid);
+		ast_copy_caller_to_connected(&connected_line, &newchan->cid);
 		ast_channel_unlock(newchan);
 		connected_line.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		ast_connected_line_update(xferchan, &connected_line);
 		ast_channel_lock(xferchan);
-		ast_party_connected_line_collect_caller(&connected_line, &xferchan->cid);
+		ast_copy_caller_to_connected(&connected_line, &xferchan->cid);
 		ast_channel_unlock(xferchan);
 		connected_line.source = AST_CONNECTED_LINE_UPDATE_SOURCE_TRANSFER;
 		ast_connected_line_update(newchan, &connected_line);
+
+		ast_party_connected_line_free(&connected);
 		
 		if (ast_stream_and_wait(newchan, xfersound, ""))
 			ast_log(LOG_WARNING, "Failed to play transfer sound!\n");




More information about the asterisk-commits mailing list