diff options
author | m0gg | 2007-01-01 22:54:46 +0000 |
---|---|---|
committer | m0gg | 2007-01-01 22:54:46 +0000 |
commit | 5502aff768e5cbc3bbd05e067bc0dfc456770f86 (patch) | |
tree | 090bf72c90a77c9c931f6bdc26cfbcb3f14ebaa7 /nanohttp/nanohttp-common.c | |
parent | 23629635c0d544c4fbbc0bd5d01dd75413942a3f (diff) | |
download | csoap-5502aff768e5cbc3bbd05e067bc0dfc456770f86.tar.gz csoap-5502aff768e5cbc3bbd05e067bc0dfc456770f86.tar.bz2 |
Header parsing error solved
Diffstat (limited to 'nanohttp/nanohttp-common.c')
-rw-r--r-- | nanohttp/nanohttp-common.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/nanohttp/nanohttp-common.c b/nanohttp/nanohttp-common.c index 9b5015e..de17bfe 100644 --- a/nanohttp/nanohttp-common.c +++ b/nanohttp/nanohttp-common.c @@ -1,5 +1,5 @@ /****************************************************************** -* $Id: nanohttp-common.c,v 1.37 2006/12/16 15:55:24 m0gg Exp $ +* $Id: nanohttp-common.c,v 1.38 2007/01/01 22:54:46 m0gg Exp $ * * CSOAP Project: A http client/server library in C * Copyright (C) 2003 Ferhat Ayaz @@ -71,8 +71,7 @@ hpairnode_new(const char *key, const char *value, hpair_t * next) if (key != NULL) { - pair->key = (char *) malloc(strlen(key) + 1); - strcpy(pair->key, key); + pair->key = strdup(key); } else { @@ -81,8 +80,7 @@ hpairnode_new(const char *key, const char *value, hpair_t * next) if (value != NULL) { - pair->value = (char *) malloc(strlen(value) + 1); - strcpy(pair->value, value); + pair->value = strdup(value); } else { @@ -99,7 +97,6 @@ hpairnode_parse(const char *str, const char *delim, hpair_t * next) { hpair_t *pair; char *key, *value; - int c; pair = (hpair_t *) malloc(sizeof(hpair_t)); pair->key = ""; @@ -110,19 +107,18 @@ hpairnode_parse(const char *str, const char *delim, hpair_t * next) if (key != NULL) { - pair->key = (char *) malloc(strlen(key) + 1); - strcpy(pair->key, key); + pair->key = strdup(key); } if (value != NULL) { - for (c = 0; value[c] == ' '; c++); /* skip white space */ - pair->value = (char *) malloc(strlen(&value[c]) + 1); - strcpy(pair->value, &value[c]); + /* skip white space */ + for (; *value == ' '; value++) ; + + pair->value = strdup(value); } return pair; } - hpair_t * hpairnode_copy(const hpair_t * src) { |