Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More detailed StatStruct show #39463

Merged
merged 3 commits into from
May 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! move platform-specific code to C, use libuv, refactor
  • Loading branch information
vtjnash committed May 31, 2021
commit 9fc7a41deda10cae2bc9e0e140b88f8d40f6b2db
4 changes: 2 additions & 2 deletions base/libc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function getpwuid(uid::Unsigned, throw_error::Bool=true)
ref_pd = Ref(Cpasswd())
ret = ccall(:jl_os_get_passwd, Cint, (Ref{Cpasswd}, UInt), ref_pd, uid)
if ret != 0
throw_error && uv_error("getpwuid", ret)
throw_error && Base.uv_error("getpwuid", ret)
return
end
pd = ref_pd[]
Expand All @@ -454,7 +454,7 @@ function getgrgid(gid::Unsigned, throw_error::Bool=true)
ref_gp = Ref(Cgroup())
ret = ccall(:jl_os_get_group, Cint, (Ref{Cgroup}, UInt), ref_gp, gid)
if ret != 0
throw_error && uv_error("getgrgid", ret)
throw_error && Base.uv_error("getgrgid", ret)
return
end
gp = ref_gp[]
Expand Down
29 changes: 14 additions & 15 deletions src/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,30 +412,29 @@ JL_DLLEXPORT int jl_os_get_group(jl_group_t *grp, size_t gid)
members++;
}

grp->groupname = (char*)malloc(name_size + mem_size);

if (grp->groupname == NULL) {
gr_mem = (char*)malloc(name_size + mem_size);
if (gr_mem == NULL) {
free(buf);
return UV_ENOMEM;
}

/* Copy the groupname */
memcpy(grp->groupname, gp.gr_name, name_size);

/* Copy the gid */
grp->gid = gp.gr_gid;

/* Copy the members */
gr_mem = grp->groupname + name_size;
grp->members = (char**) gr_mem;
grp->members[members] = NULL;
gr_mem = (char*) ((char**) gr_mem + members + 1);
for (r = 0; r < members; r++) {
grp->members[r] = gr_mem;
gr_mem = stpcpy(gr_mem, gp.gr_mem[r]);
gr_mem = stpcpy(gr_mem, gp.gr_mem[r]) + 1;
}
assert(gr_mem == (char*)grp->members + mem_size);

assert(gr_mem == buf + name_size + mem_size);
/* Copy the groupname */
grp->groupname = gr_mem;
memcpy(grp->groupname, gp.gr_name, name_size);
gr_mem += name_size;

/* Copy the gid */
grp->gid = gp.gr_gid;

free(buf);

Expand All @@ -450,12 +449,12 @@ JL_DLLEXPORT void jl_os_free_group(jl_group_t *grp)

/*
The memory for is allocated in a single uv__malloc() call. The base of the
pointer is stored in grp->groupname, so that is the only field that needs
pointer is stored in grp->members, so that is the only field that needs
to be freed.
*/
free(grp->groupname);
grp->groupname = NULL;
free(grp->members);
grp->members = NULL;
grp->groupname = NULL;
}

// --- buffer manipulation ---
Expand Down