List for cgit developers and users
 help / color / mirror / Atom feed
From: cgit at cryptocrack.de (Lukas Fleischer)
Subject: [PATCH v3] html.c: Replace strdup() with xstrdup()
Date: Sat,  6 Apr 2013 13:30:54 +0200	[thread overview]
Message-ID: <1365247854-14458-1-git-send-email-cgit@cryptocrack.de> (raw)
In-Reply-To: <1365239483-14912-1-git-send-email-cgit@cryptocrack.de>

Use the xstrdup() wrapper which already bails out if strdup() returns a
NULL pointer.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
Note that this revision is based on John's patch ("Always #include
corresponding .h in .c files") which gets a +1 from me.

 html.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/html.c b/html.c
index 1104f97..8c45ba6 100644
--- a/html.c
+++ b/html.c
@@ -6,6 +6,7 @@
  *   (see COPYING for full license text)
  */
 
+#include "cgit.h"
 #include "html.h"
 #include <unistd.h>
 #include <stdio.h>
@@ -307,11 +308,7 @@ int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const
 	if (!txt_)
 		return 0;
 
-	o = t = txt = strdup(txt_);
-	if (t == NULL) {
-		printf("Out of memory\n");
-		exit(1);
-	}
+	o = t = txt = xstrdup(txt_);
 	while ((c=*t) != '\0') {
 		if (c == '=') {
 			*t = '\0';
-- 
1.8.2.674.g2c8b7bf





  parent reply	other threads:[~2013-04-06 11:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-06  9:11 [PATCH] " cgit
2013-04-06  9:17 ` [PATCH v2] " cgit
2013-04-06  9:44   ` john
2013-04-06 10:50     ` cgit
2013-04-06 11:14       ` john
2013-04-06 11:30 ` cgit [this message]
2013-04-06 14:26   ` [PATCH v3] " Jason

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1365247854-14458-1-git-send-email-cgit@cryptocrack.de \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).