mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
[fdplane] constify args/env, kill unit test memory leaks
This commit is contained in:
parent
d51318f58c
commit
f377e30300
@ -4211,17 +4211,18 @@ typedef struct ncsubproc_options {
|
|||||||
|
|
||||||
// see exec(2). p-types use $PATH. e-type passes environment vars.
|
// see exec(2). p-types use $PATH. e-type passes environment vars.
|
||||||
API ALLOC struct ncsubproc* ncsubproc_createv(struct ncplane* n, const ncsubproc_options* opts,
|
API ALLOC struct ncsubproc* ncsubproc_createv(struct ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[],
|
const char* bin, const char* const arg[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
||||||
__attribute__ ((nonnull (1)));
|
__attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
API ALLOC struct ncsubproc* ncsubproc_createvp(struct ncplane* n, const ncsubproc_options* opts,
|
API ALLOC struct ncsubproc* ncsubproc_createvp(struct ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[],
|
const char* bin, const char* const arg[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
||||||
__attribute__ ((nonnull (1)));
|
__attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
API ALLOC struct ncsubproc* ncsubproc_createvpe(struct ncplane* n, const ncsubproc_options* opts,
|
API ALLOC struct ncsubproc* ncsubproc_createvpe(struct ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[], char* const env[],
|
const char* bin, const char* const arg[],
|
||||||
|
const char* const env[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn)
|
||||||
__attribute__ ((nonnull (1)));
|
__attribute__ ((nonnull (1)));
|
||||||
|
|
||||||
|
13
src/lib/fd.c
13
src/lib/fd.c
@ -378,21 +378,22 @@ ncexecvpe(ncplane* n, const ncsubproc_options* opts, unsigned usepath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ncsubproc* ncsubproc_createv(ncplane* n, const ncsubproc_options* opts,
|
ncsubproc* ncsubproc_createv(ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[],
|
const char* bin, const char* const arg[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
||||||
return ncexecvpe(n, opts, 0, bin, arg, NULL, cbfxn, donecbfxn);
|
return ncexecvpe(n, opts, 0, bin, (char* const *)arg, NULL, cbfxn, donecbfxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ncsubproc* ncsubproc_createvp(ncplane* n, const ncsubproc_options* opts,
|
ncsubproc* ncsubproc_createvp(ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[],
|
const char* bin, const char* const arg[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
||||||
return ncexecvpe(n, opts, 1, bin, arg, NULL, cbfxn, donecbfxn);
|
return ncexecvpe(n, opts, 1, bin, (char* const *)arg, NULL, cbfxn, donecbfxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
ncsubproc* ncsubproc_createvpe(ncplane* n, const ncsubproc_options* opts,
|
ncsubproc* ncsubproc_createvpe(ncplane* n, const ncsubproc_options* opts,
|
||||||
const char* bin, char* const arg[], char* const env[],
|
const char* bin, const char* const arg[],
|
||||||
|
const char* const env[],
|
||||||
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
ncfdplane_callback cbfxn, ncfdplane_done_cb donecbfxn){
|
||||||
return ncexecvpe(n, opts, 1, bin, arg, env, cbfxn, donecbfxn);
|
return ncexecvpe(n, opts, 1, bin, (char* const *)arg, (char* const*)env, cbfxn, donecbfxn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ncsubproc_destroy(ncsubproc* n){
|
int ncsubproc_destroy(ncsubproc* n){
|
||||||
|
@ -97,7 +97,7 @@ TEST_CASE("FdsAndSubprocs"
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
SUBCASE("SubprocDestroyCmdExecFails") {
|
SUBCASE("SubprocDestroyCmdExecFails") {
|
||||||
char * const argv[] = { strdup("/should-not-exist"), nullptr, };
|
char * const argv[] = { "/should-not-exist", nullptr, };
|
||||||
bool outofline_cancelled = false;
|
bool outofline_cancelled = false;
|
||||||
ncsubproc_options opts{};
|
ncsubproc_options opts{};
|
||||||
opts.curry = &outofline_cancelled;
|
opts.curry = &outofline_cancelled;
|
||||||
@ -116,7 +116,7 @@ TEST_CASE("FdsAndSubprocs"
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
SUBCASE("SubprocDestroyCmdSucceeds") {
|
SUBCASE("SubprocDestroyCmdSucceeds") {
|
||||||
char * const argv[] = { strdup("/bin/cat"), strdup("/dev/null"), nullptr, };
|
char const * const argv[] = { "/bin/cat", "/dev/null", nullptr, };
|
||||||
bool outofline_cancelled = false;
|
bool outofline_cancelled = false;
|
||||||
ncsubproc_options opts{};
|
ncsubproc_options opts{};
|
||||||
opts.curry = &outofline_cancelled;
|
opts.curry = &outofline_cancelled;
|
||||||
@ -135,7 +135,7 @@ TEST_CASE("FdsAndSubprocs"
|
|||||||
// assuming the path /dev/nope doesn't exist, cat ought be successfully
|
// assuming the path /dev/nope doesn't exist, cat ought be successfully
|
||||||
// launched (fork() and exec() both succeed), but then immediately fail.
|
// launched (fork() and exec() both succeed), but then immediately fail.
|
||||||
SUBCASE("SubprocDestroyCmdFailed") {
|
SUBCASE("SubprocDestroyCmdFailed") {
|
||||||
char * const argv[] = { strdup("/bin/cat"), strdup("/dev/nope"), nullptr, };
|
char const * const argv[] = { "/bin/cat", "/dev/nope", nullptr, };
|
||||||
bool outofline_cancelled = false;
|
bool outofline_cancelled = false;
|
||||||
ncsubproc_options opts{};
|
ncsubproc_options opts{};
|
||||||
opts.curry = &outofline_cancelled;
|
opts.curry = &outofline_cancelled;
|
||||||
@ -152,7 +152,7 @@ TEST_CASE("FdsAndSubprocs"
|
|||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("SubprocDestroyCmdHung") {
|
SUBCASE("SubprocDestroyCmdHung") {
|
||||||
char * const argv[] = { strdup("/bin/cat"), nullptr, };
|
char const * const argv[] = { "/bin/cat", nullptr, };
|
||||||
bool outofline_cancelled = false;
|
bool outofline_cancelled = false;
|
||||||
ncsubproc_options opts{};
|
ncsubproc_options opts{};
|
||||||
opts.curry = &outofline_cancelled;
|
opts.curry = &outofline_cancelled;
|
||||||
|
Loading…
Reference in New Issue
Block a user