[Home]

Summary:ASTERISK-05830: [patch] move duplicated code to a function
Reporter:Luigi Rizzo (rizzo)Labels:
Date Opened:2005-12-13 07:56:04.000-0600Date Closed:2008-01-15 16:07:26.000-0600
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/app_macro
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_macro.patch
Description:the attached patch moves the sequence (used 4 times in this code):

  a_long_name = some_function(...);
  if (a_long_name)
       a_long_name = strdup(a_long_name);

to a function safe_strdup() which makes the code more compact to read
and saves repeating 4 times the same variable name:

  a_long_name = safe_strdup(some_function(...));

****** ADDITIONAL INFORMATION ******

possibly other parts of the source would benefit from similar
cleanup. But one piece at a time...
Comments:By: Russell Bryant (russell) 2005-12-13 15:04:03.000-0600

I went ahead and merged this in the trunk.

If ASTERISK-4869 gets accepted, we can just the ast_strdup defined there ...

By: Digium Subversion (svnbot) 2008-01-15 16:06:38.000-0600

Repository: asterisk
Revision: 7472

U   trunk/apps/app_macro.c

------------------------------------------------------------------------
r7472 | russell | 2008-01-15 16:06:37 -0600 (Tue, 15 Jan 2008) | 2 lines

reduce some duplicated code when doing a strdup (issue ASTERISK-5830)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7472

By: Digium Subversion (svnbot) 2008-01-15 16:07:05.000-0600

Repository: asterisk
Revision: 7501

_U  team/russell/make_menuconfig/
U   team/russell/make_menuconfig/app.c
D   team/russell/make_menuconfig/apps/app_cut.c
U   team/russell/make_menuconfig/apps/app_dial.c
U   team/russell/make_menuconfig/apps/app_macro.c
U   team/russell/make_menuconfig/channel.c
U   team/russell/make_menuconfig/channels/chan_agent.c
U   team/russell/make_menuconfig/channels/chan_sip.c
U   team/russell/make_menuconfig/configs/misdn.conf.sample
U   team/russell/make_menuconfig/doc/README.misdn
U   team/russell/make_menuconfig/doc/README.variables
A   team/russell/make_menuconfig/funcs/func_cut.c
U   team/russell/make_menuconfig/pbx.c
U   team/russell/make_menuconfig/utils.c

------------------------------------------------------------------------
r7501 | russell | 2008-01-15 16:07:04 -0600 (Tue, 15 Jan 2008) | 90 lines

Merged revisions 7446,7457,7469,7471-7472,7481,7494,7496,7498 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r7446 | crichter | 2005-12-12 17:26:35 -0500 (Mon, 12 Dec 2005) | 1 line

updated the documentation and the sample config to meet the present
................
r7457 | kpfleming | 2005-12-13 01:00:17 -0500 (Tue, 13 Dec 2005) | 25 lines

Merged revisions 7448-7449,7451,7453 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7448 | kpfleming | 2005-12-12 22:25:14 -0600 (Mon, 12 Dec 2005) | 2 lines

use the stream's current point when pausing/unpausing, instead of elapsed time (which doesn't work when the stream has been skipped forward or backward) (issue ASTERISK-5743)

........
r7449 | kpfleming | 2005-12-12 22:43:38 -0600 (Mon, 12 Dec 2005) | 2 lines

only report AGENT_IDLE for callback mode agents when they are actually idle (issue ASTERISK-5748)

........
r7451 | kpfleming | 2005-12-12 23:14:27 -0600 (Mon, 12 Dec 2005) | 2 lines

ensure that hangups while incoming calls are in early state are handled properly (issue ASTERISK-5764)

........
r7453 | kpfleming | 2005-12-12 23:53:00 -0600 (Mon, 12 Dec 2005) | 2 lines

restore ability of caller to hangup calls that are still ringing (issue ASTERISK-5688)

........

................
r7469 | kpfleming | 2005-12-13 11:07:19 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7468 | kpfleming | 2005-12-13 10:06:27 -0600 (Tue, 13 Dec 2005) | 2 lines

correct broken math in tvfix() for timestamp values over one million

........

................
r7471 | kpfleming | 2005-12-13 13:54:41 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7470 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7470 | kpfleming | 2005-12-13 12:54:22 -0600 (Tue, 13 Dec 2005) | 2 lines

clarify substring documentation

........

................
r7472 | russell | 2005-12-13 17:03:06 -0500 (Tue, 13 Dec 2005) | 2 lines

reduce some duplicated code when doing a strdup (issue ASTERISK-5830)

................
r7481 | bweschke | 2005-12-14 21:49:17 -0500 (Wed, 14 Dec 2005) | 3 lines

Bug ASTERISK-5844 - Don't free the channel structure until after having sent the manager event.


................
r7494 | tilghman | 2005-12-15 12:31:52 -0500 (Thu, 15 Dec 2005) | 2 lines

Make sure the functions CUT and SORT are built.

................
r7496 | tilghman | 2005-12-15 14:05:41 -0500 (Thu, 15 Dec 2005) | 2 lines

Properly move these functions over to the funcs directory (since they no longer contain apps)

................
r7498 | tilghman | 2005-12-15 19:55:39 -0500 (Thu, 15 Dec 2005) | 3 lines

First field was truncated.
(Don't kill me; this attempted merge didn't work because the paths changed.)

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7501

By: Digium Subversion (svnbot) 2008-01-15 16:07:08.000-0600

Repository: asterisk
Revision: 7504

_U  team/russell/cli_originate/
U   team/russell/cli_originate/app.c
D   team/russell/cli_originate/apps/app_cut.c
U   team/russell/cli_originate/apps/app_dial.c
U   team/russell/cli_originate/apps/app_macro.c
U   team/russell/cli_originate/channel.c
U   team/russell/cli_originate/channels/chan_agent.c
U   team/russell/cli_originate/channels/chan_sip.c
U   team/russell/cli_originate/doc/README.variables
A   team/russell/cli_originate/funcs/func_cut.c
U   team/russell/cli_originate/pbx.c
U   team/russell/cli_originate/utils.c

------------------------------------------------------------------------
r7504 | russell | 2008-01-15 16:07:07 -0600 (Tue, 15 Jan 2008) | 86 lines

Merged revisions 7457,7469,7471-7472,7481,7494,7496,7498 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r7457 | kpfleming | 2005-12-13 01:00:17 -0500 (Tue, 13 Dec 2005) | 25 lines

Merged revisions 7448-7449,7451,7453 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7448 | kpfleming | 2005-12-12 22:25:14 -0600 (Mon, 12 Dec 2005) | 2 lines

use the stream's current point when pausing/unpausing, instead of elapsed time (which doesn't work when the stream has been skipped forward or backward) (issue ASTERISK-5743)

........
r7449 | kpfleming | 2005-12-12 22:43:38 -0600 (Mon, 12 Dec 2005) | 2 lines

only report AGENT_IDLE for callback mode agents when they are actually idle (issue ASTERISK-5748)

........
r7451 | kpfleming | 2005-12-12 23:14:27 -0600 (Mon, 12 Dec 2005) | 2 lines

ensure that hangups while incoming calls are in early state are handled properly (issue ASTERISK-5764)

........
r7453 | kpfleming | 2005-12-12 23:53:00 -0600 (Mon, 12 Dec 2005) | 2 lines

restore ability of caller to hangup calls that are still ringing (issue ASTERISK-5688)

........

................
r7469 | kpfleming | 2005-12-13 11:07:19 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7468 | kpfleming | 2005-12-13 10:06:27 -0600 (Tue, 13 Dec 2005) | 2 lines

correct broken math in tvfix() for timestamp values over one million

........

................
r7471 | kpfleming | 2005-12-13 13:54:41 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7470 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7470 | kpfleming | 2005-12-13 12:54:22 -0600 (Tue, 13 Dec 2005) | 2 lines

clarify substring documentation

........

................
r7472 | russell | 2005-12-13 17:03:06 -0500 (Tue, 13 Dec 2005) | 2 lines

reduce some duplicated code when doing a strdup (issue ASTERISK-5830)

................
r7481 | bweschke | 2005-12-14 21:49:17 -0500 (Wed, 14 Dec 2005) | 3 lines

Bug ASTERISK-5844 - Don't free the channel structure until after having sent the manager event.


................
r7494 | tilghman | 2005-12-15 12:31:52 -0500 (Thu, 15 Dec 2005) | 2 lines

Make sure the functions CUT and SORT are built.

................
r7496 | tilghman | 2005-12-15 14:05:41 -0500 (Thu, 15 Dec 2005) | 2 lines

Properly move these functions over to the funcs directory (since they no longer contain apps)

................
r7498 | tilghman | 2005-12-15 19:55:39 -0500 (Thu, 15 Dec 2005) | 3 lines

First field was truncated.
(Don't kill me; this attempted merge didn't work because the paths changed.)

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7504

By: Digium Subversion (svnbot) 2008-01-15 16:07:10.000-0600

Repository: asterisk
Revision: 7507

_U  team/russell/agent_function/
D   team/russell/agent_function/apps/app_cut.c
U   team/russell/agent_function/apps/app_macro.c
U   team/russell/agent_function/channel.c
U   team/russell/agent_function/doc/README.variables
A   team/russell/agent_function/funcs/func_cut.c
U   team/russell/agent_function/utils.c

------------------------------------------------------------------------
r7507 | russell | 2008-01-15 16:07:10 -0600 (Tue, 15 Jan 2008) | 58 lines

Merged revisions 7469,7471-7472,7481,7494,7496,7498 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r7469 | kpfleming | 2005-12-13 11:07:19 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7468 | kpfleming | 2005-12-13 10:06:27 -0600 (Tue, 13 Dec 2005) | 2 lines

correct broken math in tvfix() for timestamp values over one million

........

................
r7471 | kpfleming | 2005-12-13 13:54:41 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7470 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7470 | kpfleming | 2005-12-13 12:54:22 -0600 (Tue, 13 Dec 2005) | 2 lines

clarify substring documentation

........

................
r7472 | russell | 2005-12-13 17:03:06 -0500 (Tue, 13 Dec 2005) | 2 lines

reduce some duplicated code when doing a strdup (issue ASTERISK-5830)

................
r7481 | bweschke | 2005-12-14 21:49:17 -0500 (Wed, 14 Dec 2005) | 3 lines

Bug ASTERISK-5844 - Don't free the channel structure until after having sent the manager event.


................
r7494 | tilghman | 2005-12-15 12:31:52 -0500 (Thu, 15 Dec 2005) | 2 lines

Make sure the functions CUT and SORT are built.

................
r7496 | tilghman | 2005-12-15 14:05:41 -0500 (Thu, 15 Dec 2005) | 2 lines

Properly move these functions over to the funcs directory (since they no longer contain apps)

................
r7498 | tilghman | 2005-12-15 19:55:39 -0500 (Thu, 15 Dec 2005) | 3 lines

First field was truncated.
(Don't kill me; this attempted merge didn't work because the paths changed.)

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7507

By: Digium Subversion (svnbot) 2008-01-15 16:07:26.000-0600

Repository: asterisk
Revision: 7527

_U  team/russell/ast_malloc/
U   team/russell/ast_malloc/app.c
U   team/russell/ast_malloc/apps/app_chanspy.c
D   team/russell/ast_malloc/apps/app_cut.c
U   team/russell/ast_malloc/apps/app_dial.c
U   team/russell/ast_malloc/apps/app_macro.c
U   team/russell/ast_malloc/build_tools/make_svn_branch_name
U   team/russell/ast_malloc/cdr.c
U   team/russell/ast_malloc/channel.c
U   team/russell/ast_malloc/channels/chan_agent.c
U   team/russell/ast_malloc/channels/chan_sip.c
U   team/russell/ast_malloc/doc/README.ael
U   team/russell/ast_malloc/doc/README.variables
U   team/russell/ast_malloc/file.c
A   team/russell/ast_malloc/funcs/func_cut.c
U   team/russell/ast_malloc/include/asterisk/linkedlists.h
U   team/russell/ast_malloc/pbx.c
U   team/russell/ast_malloc/utils.c

------------------------------------------------------------------------
r7527 | russell | 2008-01-15 16:07:25 -0600 (Tue, 15 Jan 2008) | 160 lines

Merged revisions 7457,7469,7471-7472,7481,7494,7496,7498,7509,7511-7512,7514,7516,7518,7520,7522,7524 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

................
r7457 | kpfleming | 2005-12-13 01:00:17 -0500 (Tue, 13 Dec 2005) | 25 lines

Merged revisions 7448-7449,7451,7453 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7448 | kpfleming | 2005-12-12 22:25:14 -0600 (Mon, 12 Dec 2005) | 2 lines

use the stream's current point when pausing/unpausing, instead of elapsed time (which doesn't work when the stream has been skipped forward or backward) (issue ASTERISK-5743)

........
r7449 | kpfleming | 2005-12-12 22:43:38 -0600 (Mon, 12 Dec 2005) | 2 lines

only report AGENT_IDLE for callback mode agents when they are actually idle (issue ASTERISK-5748)

........
r7451 | kpfleming | 2005-12-12 23:14:27 -0600 (Mon, 12 Dec 2005) | 2 lines

ensure that hangups while incoming calls are in early state are handled properly (issue ASTERISK-5764)

........
r7453 | kpfleming | 2005-12-12 23:53:00 -0600 (Mon, 12 Dec 2005) | 2 lines

restore ability of caller to hangup calls that are still ringing (issue ASTERISK-5688)

........

................
r7469 | kpfleming | 2005-12-13 11:07:19 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7468 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7468 | kpfleming | 2005-12-13 10:06:27 -0600 (Tue, 13 Dec 2005) | 2 lines

correct broken math in tvfix() for timestamp values over one million

........

................
r7471 | kpfleming | 2005-12-13 13:54:41 -0500 (Tue, 13 Dec 2005) | 10 lines

Merged revisions 7470 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7470 | kpfleming | 2005-12-13 12:54:22 -0600 (Tue, 13 Dec 2005) | 2 lines

clarify substring documentation

........

................
r7472 | russell | 2005-12-13 17:03:06 -0500 (Tue, 13 Dec 2005) | 2 lines

reduce some duplicated code when doing a strdup (issue ASTERISK-5830)

................
r7481 | bweschke | 2005-12-14 21:49:17 -0500 (Wed, 14 Dec 2005) | 3 lines

Bug ASTERISK-5844 - Don't free the channel structure until after having sent the manager event.


................
r7494 | tilghman | 2005-12-15 12:31:52 -0500 (Thu, 15 Dec 2005) | 2 lines

Make sure the functions CUT and SORT are built.

................
r7496 | tilghman | 2005-12-15 14:05:41 -0500 (Thu, 15 Dec 2005) | 2 lines

Properly move these functions over to the funcs directory (since they no longer contain apps)

................
r7498 | tilghman | 2005-12-15 19:55:39 -0500 (Thu, 15 Dec 2005) | 3 lines

First field was truncated.
(Don't kill me; this attempted merge didn't work because the paths changed.)

................
r7509 | tilghman | 2005-12-16 20:07:44 -0500 (Fri, 16 Dec 2005) | 3 lines

Merged revisions 7508 via svnmerge from
/branches/1.2

................
r7511 | kpfleming | 2005-12-16 21:21:36 -0500 (Fri, 16 Dec 2005) | 2 lines

block a commit to a module that no longer exists in trunk

................
r7512 | kpfleming | 2005-12-16 21:22:24 -0500 (Fri, 16 Dec 2005) | 10 lines

Merged revision 7510 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7510 | kpfleming | 2005-12-16 20:20:04 -0600 (Fri, 16 Dec 2005) | 2 lines

fix some buglet when building team branch version strings

........

................
r7514 | kpfleming | 2005-12-16 22:45:25 -0500 (Fri, 16 Dec 2005) | 10 lines

Merged revisions 7513 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7513 | kpfleming | 2005-12-16 21:44:30 -0600 (Fri, 16 Dec 2005) | 2 lines

forcibly expire previous subscriptions from a peer when they resubscribe (keeps them from building up and waiting for expiration, and stops us sending unwanted NOTIFY messages to devices)

........

................
r7516 | kpfleming | 2005-12-16 22:59:27 -0500 (Fri, 16 Dec 2005) | 10 lines

Merged revisions 7515 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r7515 | kpfleming | 2005-12-16 21:59:05 -0600 (Fri, 16 Dec 2005) | 2 lines

Max-Forwards headers must only be present on requests, not responses

........

................
r7518 | tilghman | 2005-12-17 12:22:24 -0500 (Sat, 17 Dec 2005) | 3 lines

Merged revisions 7517 via svnmerge from
/branches/1.2

................
r7520 | tilghman | 2005-12-17 13:58:57 -0500 (Sat, 17 Dec 2005) | 3 lines

Merged revisions 7519 via svnmerge from
/branches/1.2

................
r7522 | tilghman | 2005-12-19 00:42:55 -0500 (Mon, 19 Dec 2005) | 3 lines

Merged revisions 7521 via svnmerge from
/branches/1.2

................
r7524 | tilghman | 2005-12-19 14:08:42 -0500 (Mon, 19 Dec 2005) | 3 lines

Merged revisions 7523 via svnmerge from
/branches/1.2

................

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=7527