2016-11-02 18:09:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "ipfs/thirdparty/ipfsaddr/ipfs_addr.h"
|
|
|
|
|
2016-12-01 18:08:30 +00:00
|
|
|
int ipfsaddr_new(struct IPFSAddr** addr, char* string) {
|
|
|
|
(*addr) = malloc(sizeof(struct IPFSAddr));
|
2016-11-02 18:09:38 +00:00
|
|
|
(*addr)->entire_string = malloc(sizeof(char) * (strlen(string) + 1));
|
|
|
|
if ((*addr)->entire_string == NULL)
|
|
|
|
return 0;
|
|
|
|
strncpy((*addr)->entire_string, string, strlen(string));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int ipfsaddr_free(struct IPFSAddr* addr) {
|
2016-12-01 18:08:30 +00:00
|
|
|
if (addr != NULL) {
|
|
|
|
if (addr->entire_string != NULL)
|
|
|
|
free(addr->entire_string);
|
|
|
|
free(addr);
|
|
|
|
}
|
2016-11-02 18:09:38 +00:00
|
|
|
return 1;
|
|
|
|
}
|