[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18488 - monkey/src/monkey
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18488 - monkey/src/monkey |
Date: |
Wed, 7 Dec 2011 10:04:41 +0100 |
Author: grothoff
Date: 2011-12-07 10:04:41 +0100 (Wed, 07 Dec 2011)
New Revision: 18488
Modified:
monkey/src/monkey/action_api.c
Log:
fix bug in space allocation for string
Modified: monkey/src/monkey/action_api.c
===================================================================
--- monkey/src/monkey/action_api.c 2011-12-07 08:51:16 UTC (rev 18487)
+++ monkey/src/monkey/action_api.c 2011-12-07 09:04:41 UTC (rev 18488)
@@ -606,47 +606,24 @@
}
-static int
-getExpressionListSize (struct Expression *head)
-{
- int size, count = 0;
- struct Expression *tmp = head;
-
- while (NULL != tmp)
- {
- count++;
- tmp = tmp->next;
- }
- /* Since the faulty expression is the longest in the expression list */
- size = count * strlen (faultyExpression->expressionSyntax) * sizeof (char);
- return size;
-}
-
-
static const char *
expressionListToString (struct Expression *head)
{
- char *string = GNUNET_malloc (getExpressionListSize (head));
+ char *string = GNUNET_strdup ("");
char *strTmp;
- struct Expression *tmp = head;
+ struct Expression *tmp;
- GNUNET_asprintf (&strTmp, "%s = %s\n", tmp->expressionSyntax,
- NULL ==
- tmp->expressionValue ? "Not evaluated" : tmp->
- expressionValue);
- strcpy (string, strTmp);
- GNUNET_free (strTmp);
- tmp = tmp->next;
-
- while (NULL != tmp)
+ for (tmp = head; NULL != tmp; tmp = tmp->next)
{
- GNUNET_asprintf (&strTmp, "%s = %s\n", tmp->expressionSyntax,
+ GNUNET_asprintf (&strTmp,
+ "%s%s = %s\n",
+ string,
+ tmp->expressionSyntax,
NULL ==
tmp->expressionValue ? "Not evaluated" : tmp->
expressionValue);
- strcat (string, strTmp);
- GNUNET_free (strTmp);
- tmp = tmp->next;
+ GNUNET_free (string);
+ string = strTmp;
}
return string;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18488 - monkey/src/monkey,
gnunet <=