summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Behrens <sbehrens@giantdisaster.de>2013-04-09 19:08:41 +0200
committerDavid Sterba <dsterba@suse.cz>2013-04-23 18:56:24 +0200
commit7c04a4444e5cec0691cb91660011fb614ddace94 (patch)
tree3b110c5605352b0291c3827b7d14e2f9b95b48e1
parent46de1a6ec3dbb0db203baa6c46cb64ba9b000ea2 (diff)
Btrfs-progs: don't allocate one byte too much each time
str1 + '/' + str2 + '\0' requires a buffer with the size strlen(str1) + strlen(str2) + 2 bytes. str1 + '/' + str2 + '/' + str3 + '\0' requires a buffer with the size strlen(str1) + strlen(str2) + strlen(str3) + 3 bytes. Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
-rw-r--r--send-utils.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/send-utils.c b/send-utils.c
index 182778a5..bc0feb83 100644
--- a/send-utils.c
+++ b/send-utils.c
@@ -332,7 +332,7 @@ char *path_cat(const char *p1, const char *p2)
{
int p1_len = strlen(p1);
int p2_len = strlen(p2);
- char *new = malloc(p1_len + p2_len + 3);
+ char *new = malloc(p1_len + p2_len + 2);
if (p1_len && p1[p1_len - 1] == '/')
p1_len--;
@@ -348,7 +348,7 @@ char *path_cat3(const char *p1, const char *p2, const char *p3)
int p1_len = strlen(p1);
int p2_len = strlen(p2);
int p3_len = strlen(p3);
- char *new = malloc(p1_len + p2_len + p3_len + 4);
+ char *new = malloc(p1_len + p2_len + p3_len + 3);
if (p1_len && p1[p1_len - 1] == '/')
p1_len--;