Commit 6b95e7b6 authored by hpi1's avatar hpi1

examples: fix compiling with c++ compiler

parent 898f4691
......@@ -51,7 +51,7 @@ static const char *_hex2str(const uint8_t *data, size_t len)
static char *str = NULL;
size_t i;
str = realloc(str, 2*len + 1);
str = (char*)realloc(str, 2*len + 1);
*str = 0;
for (i = 0; i < len; i++) {
......
......@@ -158,7 +158,7 @@ _mk_path(const char *base, const char *sub)
{
size_t n1 = strlen(base);
size_t n2 = strlen(sub);
char *result = malloc(n1 + n2 + strlen(DIR_SEP) + 1);
char *result = (char*)malloc(n1 + n2 + strlen(DIR_SEP) + 1);
strcpy(result, base);
strcat(result, DIR_SEP);
strcat(result, sub);
......@@ -753,11 +753,11 @@ main(int argc, char *argv[])
}
}
if (dir != NULL) {
char **dirlist = calloc(10001, sizeof(char*));
char **dirlist = (char**)calloc(10001, sizeof(char*));
struct dirent *ent;
int jj = 0;
for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
dirlist[jj++] = strcpy(malloc(strlen(ent->d_name)), ent->d_name);
dirlist[jj++] = strcpy((char*)malloc(strlen(ent->d_name)), ent->d_name);
}
qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp);
for (jj = 0; dirlist[jj] != NULL; jj++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment