Skip to content

Commit

Permalink
use glib for strndup (osx < lion missing strndup)
Browse files Browse the repository at this point in the history
  • Loading branch information
benlemasurier committed Jan 27, 2012
1 parent bbd3707 commit ed0ca64
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/curl.c
Expand Up @@ -449,7 +449,7 @@ get_upload_id(char *xml)
start_p = strstr(xml, start_marker) + strlen(start_marker);
end_p = strstr(xml, end_marker);

return strndup(start_p, end_p - start_p);
return g_strndup(start_p, end_p - start_p);
}

static char *
Expand All @@ -463,7 +463,7 @@ get_etag_from_xml(char *xml)
start_p = strstr(xml, start_marker) + strlen(start_marker);
end_p = strstr(xml, end_marker);

tmp = strndup(start_p, end_p - start_p);
tmp = g_strndup(start_p, end_p - start_p);
if(asprintf(&etag, "\"%s\"", tmp) == -1) {
fprintf(stderr, "unable to allocate memory\n");
exit(EXIT_FAILURE);
Expand Down
6 changes: 3 additions & 3 deletions src/stormfs.c
Expand Up @@ -389,7 +389,7 @@ cache_invalidate_dir(const char *path)
if(s == path)
g_hash_table_remove(cache.files, "/");
else {
char *parent = strndup(path, s - path);
char *parent = g_strndup(path, s - path);
cache_invalidate(parent);
free(parent);
}
Expand Down Expand Up @@ -1125,7 +1125,7 @@ xml_to_files(const char *path, char *xml)
char *fullpath;
char *end_p = strstr(start_p, "</Key>");

name = strndup(start_p, end_p - start_p);
name = g_strndup(start_p, end_p - start_p);
fullpath = get_path(path, name);
files = add_file_to_list(files, fullpath, NULL);
free(name);
Expand Down Expand Up @@ -1363,7 +1363,7 @@ stormfs_rename_directory(const char *from, const char *to)
char *end_p = strstr(start_p, "</Key>");
struct stat st;

tmp = strndup(start_p, end_p - start_p);
tmp = g_strndup(start_p, end_p - start_p);
name = basename(tmp);
file_from = get_path(from, name);
file_to = get_path(to, name);
Expand Down

0 comments on commit ed0ca64

Please sign in to comment.