aboutsummaryrefslogtreecommitdiffstats
path: root/cgit.c
diff options
context:
space:
mode:
authorGravatar Lukas Fleischer <cgit@cryptocrack.de>2013-04-02 00:11:15 (JST)
committerGravatar Jason A. Donenfeld <Jason@zx2c4.com>2013-04-08 22:43:17 (JST)
commita92678b5f119811bccaca9c31b779c5ceed95572 (patch)
treea990fc6e9b1248f9546b6865a2e81dacd1263254 /cgit.c
parent3a8432437934a0a95f2618b534b1f5b3494d6b18 (diff)
downloadcgit-a92678b5f119811bccaca9c31b779c5ceed95572.zip
cgit-a92678b5f119811bccaca9c31b779c5ceed95572.tar.gz
Do not unnecessarily strdup() environment variables
This reverts the memory duplication introduced in commit 60a2627, while keeping everything else that has been cleaned up. The environment variables are never modified, so we do not need to call xstrdupn() here. Also, remove xstrdupn() which is no longer needed. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de>
Diffstat (limited to 'cgit.c')
-rw-r--r--cgit.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/cgit.c b/cgit.c
index d145f8a..ca3034c 100644
--- a/cgit.c
+++ b/cgit.c
@@ -333,11 +333,6 @@ static void querystring_cb(const char *name, const char *value)
333 } 333 }
334} 334}
335 335
336static char *xstrdupn(const char *str)
337{
338 return (str ? xstrdup(str) : NULL);
339}
340
341static void prepare_context(struct cgit_context *ctx) 336static void prepare_context(struct cgit_context *ctx)
342{ 337{
343 memset(ctx, 0, sizeof(*ctx)); 338 memset(ctx, 0, sizeof(*ctx));
@@ -382,16 +377,16 @@ static void prepare_context(struct cgit_context *ctx)
382 ctx->cfg.summary_tags = 10; 377 ctx->cfg.summary_tags = 10;
383 ctx->cfg.max_atom_items = 10; 378 ctx->cfg.max_atom_items = 10;
384 ctx->cfg.ssdiff = 0; 379 ctx->cfg.ssdiff = 0;
385 ctx->env.cgit_config = xstrdupn(getenv("CGIT_CONFIG")); 380 ctx->env.cgit_config = getenv("CGIT_CONFIG");
386 ctx->env.http_host = xstrdupn(getenv("HTTP_HOST")); 381 ctx->env.http_host = getenv("HTTP_HOST");
387 ctx->env.https = xstrdupn(getenv("HTTPS")); 382 ctx->env.https = getenv("HTTPS");
388 ctx->env.no_http = xstrdupn(getenv("NO_HTTP")); 383 ctx->env.no_http = getenv("NO_HTTP");
389 ctx->env.path_info = xstrdupn(getenv("PATH_INFO")); 384 ctx->env.path_info = getenv("PATH_INFO");
390 ctx->env.query_string = xstrdupn(getenv("QUERY_STRING")); 385 ctx->env.query_string = getenv("QUERY_STRING");
391 ctx->env.request_method = xstrdupn(getenv("REQUEST_METHOD")); 386 ctx->env.request_method = getenv("REQUEST_METHOD");
392 ctx->env.script_name = xstrdupn(getenv("SCRIPT_NAME")); 387 ctx->env.script_name = getenv("SCRIPT_NAME");
393 ctx->env.server_name = xstrdupn(getenv("SERVER_NAME")); 388 ctx->env.server_name = getenv("SERVER_NAME");
394 ctx->env.server_port = xstrdupn(getenv("SERVER_PORT")); 389 ctx->env.server_port = getenv("SERVER_PORT");
395 ctx->page.mimetype = "text/html"; 390 ctx->page.mimetype = "text/html";
396 ctx->page.charset = PAGE_ENCODING; 391 ctx->page.charset = PAGE_ENCODING;
397 ctx->page.filename = NULL; 392 ctx->page.filename = NULL;