Fixed PathFromCid(), Cid is an struct, not an array.

This commit is contained in:
Jose Marcial Vieira Bisneto 2016-11-17 17:47:31 -03:00
parent 1a8e024fb9
commit 8ed4f62526
2 changed files with 6 additions and 5 deletions

View file

@ -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);

View file

@ -1,16 +1,17 @@
#include <string.h>
#include <stdlib.h>
#include <ipfs/cid/cid.h>
#include <ipfs/path/path.h>
// 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;
}