summaryrefslogtreecommitdiff
path: root/3rdparty/libconfig/scanctx.c
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-04 17:08:44 +0300
committerAndrei Karas <akaras@inbox.ru>2016-04-04 17:08:44 +0300
commit3732bd4a6b708651f6b4bcd32d6beb2b7f49c478 (patch)
tree83155915c35c72d018108231437248cc78d5060d /3rdparty/libconfig/scanctx.c
parent0bd30a0fac1db1b478b3173a22a81bd5249113f8 (diff)
parent9147fe9473b26ee32aafed65fd02b03f11397629 (diff)
downloadhercules-3732bd4a6b708651f6b4bcd32d6beb2b7f49c478.tar.gz
hercules-3732bd4a6b708651f6b4bcd32d6beb2b7f49c478.tar.bz2
hercules-3732bd4a6b708651f6b4bcd32d6beb2b7f49c478.tar.xz
hercules-3732bd4a6b708651f6b4bcd32d6beb2b7f49c478.zip
Merge pull request #1210 from HerculesWS/wcast_qual
Added -Wcast-qual compiler flag
Diffstat (limited to '3rdparty/libconfig/scanctx.c')
-rw-r--r--3rdparty/libconfig/scanctx.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/3rdparty/libconfig/scanctx.c b/3rdparty/libconfig/scanctx.c
index b3d9a6379..94ba73edd 100644
--- a/3rdparty/libconfig/scanctx.c
+++ b/3rdparty/libconfig/scanctx.c
@@ -38,25 +38,23 @@ static const char *err_include_too_deep = "include file nesting too deep";
/* ------------------------------------------------------------------------- */
static const char *__scanctx_add_filename(struct scan_context *ctx,
- const char *filename)
+ char *filename)
{
unsigned int count = ctx->num_filenames;
- const char **f;
+ char **f;
for(f = ctx->filenames; count > 0; ++f, --count)
{
if(!strcmp(*f, filename))
{
- free((void *)filename);
+ free(filename);
return(*f); /* already in list */
}
}
if((ctx->num_filenames % CHUNK_SIZE) == 0)
{
- ctx->filenames = (const char **)realloc(
- (void *)ctx->filenames,
- (ctx->num_filenames + CHUNK_SIZE) * sizeof(const char *));
+ ctx->filenames = realloc(ctx->filenames, (ctx->num_filenames + CHUNK_SIZE) * sizeof(char *));
}
ctx->filenames[ctx->num_filenames] = filename;
@@ -69,16 +67,14 @@ static const char *__scanctx_add_filename(struct scan_context *ctx,
void scanctx_init(struct scan_context *ctx, const char *top_filename)
{
memset(ctx, 0, sizeof(struct scan_context));
-#ifndef __clang_analyzer__ // FIXME: Clang's static analyzer doesn't like this
if(top_filename)
ctx->top_filename = __scanctx_add_filename(ctx, strdup(top_filename));
-#endif // __clang_analyzer__
}
/* ------------------------------------------------------------------------- */
-const char **scanctx_cleanup(struct scan_context *ctx,
- unsigned int *num_filenames)
+char **scanctx_cleanup(struct scan_context *ctx,
+ unsigned int *num_filenames)
{
int i;
@@ -97,7 +93,7 @@ FILE *scanctx_push_include(struct scan_context *ctx, void *buffer,
const char **error)
{
FILE *fp = NULL;
- const char *file;
+ char *file;
char *full_file = NULL;
*error = NULL;
@@ -119,20 +115,18 @@ FILE *scanctx_push_include(struct scan_context *ctx, void *buffer,
}
fp = fopen(full_file ? full_file : file, "rt");
- free((void *)full_file);
+ free(full_file);
if(fp)
{
ctx->streams[ctx->depth] = fp;
-#ifndef __clang_analyzer__ // FIXME: Clang's static analyzer doesn't like this
ctx->files[ctx->depth] = __scanctx_add_filename(ctx, file);
-#endif // __clang_analyzer__
ctx->buffers[ctx->depth] = buffer;
++(ctx->depth);
}
else
{
- free((void *)file);
+ free(file);
*error = err_bad_include;
}