From 8ed4f625264379496519c806613f5b8566f53766 Mon Sep 17 00:00:00 2001 From: Jose Marcial Vieira Bisneto Date: Thu, 17 Nov 2016 17:47:31 -0300 Subject: [PATCH] Fixed PathFromCid(), Cid is an struct, not an array. --- include/ipfs/path/path.h | 2 +- path/path.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/ipfs/path/path.h b/include/ipfs/path/path.h index 9d48c3d..ba3b81e 100644 --- a/include/ipfs/path/path.h +++ b/include/ipfs/path/path.h @@ -20,7 +20,7 @@ ErrNoLinkFmt } PathErrs; - char* PathFromCid (char *c); + char* PathFromCid (struct Cid *c); char** Segments (char *p); int SegmentsLength (char **s); void FreeSegments (char ***s); diff --git a/path/path.c b/path/path.c index f649ccb..ba294be 100644 --- a/path/path.c +++ b/path/path.c @@ -1,16 +1,17 @@ #include #include +#include #include // FromCid safely converts a cid.Cid type to a Path type -char* PathFromCid (char *c) +char* PathFromCid (struct Cid *c) { - char *rpath; + char *rpath, *cidstr = CidString(c); - rpath = malloc(strlen(c) + 7); + rpath = malloc(strlen(cidstr) + 7); if (!rpath) return NULL; strcpy(rpath, "/ipfs/"); - strcat(rpath, c); + strcat(rpath, cidstr); return rpath; }