Idefisk
Tools
Tutorials
Reviews
VoIP Providers
Archives
AsteriskGuru Archives
Mailing List Archives
FAQ
Search
Memberlist
Usergroups
Register
Profile
Log in to check your private messages
Log in
[Asterisk-Dev] strdupa not common
AsteriskGuru Archives Forum Index
->
Asterisk-Dev
View previous topic
::
View next topic
Author
Message
asterisk-dev at lists.dig
Guest
Posted: Wed Apr 23, 2003 5:02 pm
Post subject: [Asterisk-Dev] strdupa not common
strdupa() is not at all common -- this diff changes it to a
combination of alloca and strcpy
Index: indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/indications.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 indications.c
--- indications.c 16 Mar 2003 22:37:29 -0000 1.1.1.2
+++ indications.c 23 Apr 2003 16:49:41 -0000
@@ -140,11 +140,12 @@
int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, int interruptible)
{
- char *s, *data = strdupa(playlst); /* cute */
+ char *s, *data = alloca(strlen(playlst)+1); /* cute */
struct playtones_def d = { vol, -1, 0, 1, NULL};
char *stringp=NULL;
if (!data)
return -1;
+ strcpy(data,playlst);
if (vol < 1)
d.vol = 8192;
Index: channels/chan_modem.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_modem.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 chan_modem.c
--- channels/chan_modem.c 12 Feb 2003 13:59:14 -0000 1.1.1.1
+++ channels/chan_modem.c 23 Apr 2003 16:49:46 -0000
@@ -808,12 +808,13 @@
char *piece;
int start, finish,x;
unsigned int group = 0;
- char *copy = strdupa(s);
+ char *copy = alloca(strlen(s) + 1);
char *stringp=NULL;
if (!copy) {
ast_log(LOG_ERROR, "Out of memory\n");
return 0;
}
+ strcpy(copy, s);
stringp=copy;
piece = strsep(&stringp, ",");
while(piece) {
Index: res/res_indications.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_indications.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 res_indications.c
--- res/res_indications.c 16 Mar 2003 22:37:31 -0000 1.1.1.2
+++ res/res_indications.c 23 Apr 2003 17:00:50 -0000
@@ -248,7 +248,8 @@
if (!strcasecmp(v->name, "description")) {
strncpy(tones->description, v->value, sizeof(tones->description)-1);
} else if (!strcasecmp(v->name,"ringcadance")) {
- char *ring,*rings = strdupa(v->value);
+ char *ring,*rings = alloca(strlen(v->value) + 1);
+ strcpy(rings, v->value);
c = rings;
ring = strsep(&c,",");
while (ring) {
@@ -270,7 +271,8 @@
ring = strsep(&c,",");
}
} else if (!strcasecmp(v->name,"alias")) {
- char *countries = strdupa(v->value);
+ char *countries = alloca(strlen(v->value) + 1);
+ strcpy(countries, v->value);
c = countries;
country = strsep(&c,",");
while (country) {
Index: res/res_parking.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_parking.c,v
retrieving revision 1.2
diff -u -r1.2 res_parking.c
--- res/res_parking.c 9 Apr 2003 04:00:43 -0000 1.2
+++ res/res_parking.c 23 Apr 2003 17:00:52 -0000
@@ -611,11 +611,12 @@
char *c=NULL;
int start=0, finish=0,x;
unsigned int group = 0;
- copy = strdupa(s);
+ copy = alloca(strlen(s) + 1);
if (!copy) {
ast_log(LOG_ERROR, "Out of memory\n");
return 0;
}
+ strcpy(copy, s);
c = copy;
while((piece = strsep(&c, ","))) {
--
Thorsten Lockert |
tholo@sigmasoft.com
| Universe, n.:
2121 N. Lakeshore Dr. |
tholo@openbsd.org
| The problem.
Chapel Hill, NC 27514 | |
Back to top
Display posts from previous:
All Posts
1 Day
7 Days
2 Weeks
1 Month
3 Months
6 Months
1 Year
Oldest First
Newest First
AsteriskGuru Archives Forum Index
->
Asterisk-Dev
All times are GMT
Page
1
of
1
Jump to:
Select a forum
Asterisk Mailing Lists
----------------
Asterisk-Users
Asterisk-Dev
Asterisk-CVS
Asterisk-Biz
Asterisk-Doc
Asterisk-BSD
Asterisk-Announce
Asterisk Call Centers
Asterisk-Video
Asterisk-Speech-Rec
Bristuff-Users
You
cannot
post new topics in this forum
You
cannot
reply to topics in this forum
You
cannot
edit your posts in this forum
You
cannot
delete your posts in this forum
You
cannot
vote in polls in this forum
Powered by
phpBB
© 2001, 2005 phpBB Group