[svn-commits] trunk - r8411 /trunk/pbx.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Sat Jan 21 16:05:20 MST 2006
Author: russell
Date: Sat Jan 21 17:05:19 2006
New Revision: 8411
URL: http://svn.digium.com/view/asterisk?rev=8411&view=rev
Log:
const-ify some fields in the ast_exten and ast_include structures (issue #6270)
Modified:
trunk/pbx.c
Modified: trunk/pbx.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx.c?rev=8411&r1=8410&r2=8411&view=diff
==============================================================================
--- trunk/pbx.c (original)
+++ trunk/pbx.c Sat Jan 21 17:05:19 2006
@@ -112,11 +112,11 @@
struct ast_exten {
char *exten; /*!< Extension name */
int matchcid; /*!< Match caller id ? */
- char *cidmatch; /*!< Caller id to match for this extension */
+ const char *cidmatch; /*!< Caller id to match for this extension */
int priority; /*!< Priority */
- char *label; /*!< Label */
+ const char *label; /*!< Label */
struct ast_context *parent; /*!< The context this extension belongs to */
- char *app; /*!< Application to execute */
+ const char *app; /*!< Application to execute */
void *data; /*!< Data to use (arguments) */
void (*datad)(void *); /*!< Data destructor */
struct ast_exten *peer; /*!< Next higher priority with our extension */
@@ -127,8 +127,8 @@
/*! \brief ast_include: include= support in extensions.conf */
struct ast_include {
- char *name;
- char *rname; /*!< Context to include */
+ const char *name;
+ const char *rname; /*!< Context to include */
const char *registrar; /*!< Registrar */
int hastime; /*!< If time construct exists */
struct ast_timing timing; /*!< time construct */
@@ -151,7 +151,7 @@
struct ast_ignorepat {
const char *registrar;
struct ast_ignorepat *next;
- char pattern[0];
+ const char pattern[0];
};
/*! \brief ast_context: An extension context */
@@ -3881,21 +3881,19 @@
return -1;
}
- /* ... fill in this structure ... */
+ /* Fill in this structure. Use 'p' for assignments, as the fields
+ * in the structure are 'const char *'
+ */
p = new_include->stuff;
new_include->name = p;
- strcpy(new_include->name, value);
+ strcpy(p, value);
p += strlen(value) + 1;
new_include->rname = p;
- strcpy(new_include->rname, value);
- c = new_include->rname;
- /* Strip off timing info */
- while(*c && (*c != '|'))
- c++;
- /* Process if it's there */
- if (*c) {
- new_include->hastime = ast_build_timing(&(new_include->timing), c+1);
- *c = '\0';
+ strcpy(p, value);
+ /* Strip off timing info, and process if it is there */
+ if ( (c = strchr(p, '|')) ) {
+ *c++ = '\0';
+ new_include->hastime = ast_build_timing(&(new_include->timing), c);
}
new_include->next = NULL;
new_include->registrar = registrar;
@@ -4137,7 +4135,10 @@
errno = ENOMEM;
return -1;
}
- strcpy(ignorepat->pattern, value);
+ /* The cast to char * is because we need to write the initial value.
+ * The field is not supposed to be modified otherwise
+ */
+ strcpy((char *)ignorepat->pattern, value);
ignorepat->next = NULL;
ignorepat->registrar = registrar;
ast_mutex_lock(&con->lock);
@@ -4371,26 +4372,26 @@
datad = null_datad;
tmp = calloc(1, length);
if (tmp) {
+ /* use p as dst in assignments, as the fields are const char * */
p = tmp->stuff;
if (label) {
tmp->label = p;
- strcpy(tmp->label, label);
+ strcpy(p, label);
p += strlen(label) + 1;
}
tmp->exten = p;
- p += ext_strncpy(tmp->exten, extension, strlen(extension) + 1) + 1;
+ p += ext_strncpy(p, extension, strlen(extension) + 1) + 1;
tmp->priority = priority;
- tmp->cidmatch = p;
+ tmp->cidmatch = p; /* but use p for assignments below */
if (callerid) {
- p += ext_strncpy(tmp->cidmatch, callerid, strlen(callerid) + 1) + 1;
+ p += ext_strncpy(p, callerid, strlen(callerid) + 1) + 1;
tmp->matchcid = 1;
} else {
- tmp->cidmatch[0] = '\0';
+ *p++ = '\0';
tmp->matchcid = 0;
- p++;
}
tmp->app = p;
- strcpy(tmp->app, application);
+ strcpy(p, application);
tmp->parent = con;
tmp->data = data;
tmp->datad = datad;
More information about the svn-commits
mailing list