mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 10:33:13 +00:00
Merged revisions 49551 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r49551 | file | 2007-01-04 17:28:29 -0500 (Thu, 04 Jan 2007) | 2 lines Only free comments and line buffer once we reach the first level. (issue #8678 reported by ssokol, fixed by anthonyl) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@49552 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -86,6 +86,8 @@ static void CB_INIT(void)
|
|||||||
comment_buffer[0] = 0;
|
comment_buffer[0] = 0;
|
||||||
comment_buffer_size = CB_INCR;
|
comment_buffer_size = CB_INCR;
|
||||||
lline_buffer = ast_malloc(CB_INCR);
|
lline_buffer = ast_malloc(CB_INCR);
|
||||||
|
if (!lline_buffer)
|
||||||
|
return;
|
||||||
lline_buffer[0] = 0;
|
lline_buffer[0] = 0;
|
||||||
lline_buffer_size = CB_INCR;
|
lline_buffer_size = CB_INCR;
|
||||||
} else {
|
} else {
|
||||||
@@ -127,7 +129,7 @@ static void LLB_ADD(char *str)
|
|||||||
int siz = strlen(str);
|
int siz = strlen(str);
|
||||||
if (rem < siz+1) {
|
if (rem < siz+1) {
|
||||||
lline_buffer = ast_realloc(lline_buffer, lline_buffer_size + CB_INCR + siz + 1);
|
lline_buffer = ast_realloc(lline_buffer, lline_buffer_size + CB_INCR + siz + 1);
|
||||||
if (!lline_buffer)
|
if (!lline_buffer)
|
||||||
return;
|
return;
|
||||||
lline_buffer_size += CB_INCR + siz + 1;
|
lline_buffer_size += CB_INCR + siz + 1;
|
||||||
}
|
}
|
||||||
@@ -167,6 +169,7 @@ static struct ast_config_engine *config_engine_list;
|
|||||||
struct ast_category {
|
struct ast_category {
|
||||||
char name[80];
|
char name[80];
|
||||||
int ignored; /*!< do not let user of the config see this category */
|
int ignored; /*!< do not let user of the config see this category */
|
||||||
|
int include_level;
|
||||||
struct ast_comment *precomments;
|
struct ast_comment *precomments;
|
||||||
struct ast_comment *sameline;
|
struct ast_comment *sameline;
|
||||||
struct ast_variable *root;
|
struct ast_variable *root;
|
||||||
@@ -339,6 +342,7 @@ void ast_category_append(struct ast_config *config, struct ast_category *categor
|
|||||||
config->last->next = category;
|
config->last->next = category;
|
||||||
else
|
else
|
||||||
config->root = category;
|
config->root = category;
|
||||||
|
category->include_level = config->include_level;
|
||||||
config->last = category;
|
config->last = category;
|
||||||
config->current = category;
|
config->current = category;
|
||||||
}
|
}
|
||||||
@@ -796,8 +800,11 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
|
|
||||||
if (withcomments) {
|
if (withcomments) {
|
||||||
CB_INIT();
|
CB_INIT();
|
||||||
|
if (!lline_buffer || !comment_buffer) {
|
||||||
|
ast_log(LOG_ERROR, "Failed to initialize the comment buffer!\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef AST_INCLUDE_GLOB
|
#ifdef AST_INCLUDE_GLOB
|
||||||
{
|
{
|
||||||
int glob_ret;
|
int glob_ret;
|
||||||
@@ -847,7 +854,8 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
while(!feof(f)) {
|
while(!feof(f)) {
|
||||||
lineno++;
|
lineno++;
|
||||||
if (fgets(buf, sizeof(buf), f)) {
|
if (fgets(buf, sizeof(buf), f)) {
|
||||||
if ( withcomments ) {
|
if ( withcomments ) {
|
||||||
|
ast_log(LOG_NOTICE, "moo\n");
|
||||||
CB_ADD(lline_buffer); /* add the current lline buffer to the comment buffer */
|
CB_ADD(lline_buffer); /* add the current lline buffer to the comment buffer */
|
||||||
lline_buffer[0] = 0; /* erase the lline buffer */
|
lline_buffer[0] = 0; /* erase the lline buffer */
|
||||||
}
|
}
|
||||||
@@ -937,16 +945,16 @@ static struct ast_config *config_text_file_load(const char *database, const char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (withcomments) {
|
|
||||||
if (comment_buffer) {
|
if (cfg->include_level == 1 && withcomments && comment_buffer) {
|
||||||
free(comment_buffer);
|
free(comment_buffer);
|
||||||
free(lline_buffer);
|
free(lline_buffer);
|
||||||
comment_buffer=0;
|
comment_buffer = NULL;
|
||||||
lline_buffer=0;
|
lline_buffer = NULL;
|
||||||
comment_buffer_size=0;
|
comment_buffer_size = 0;
|
||||||
lline_buffer_size=0;
|
lline_buffer_size = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user