From efb891d82e461964809c23405d6e1d23e066c49aa7d6797dfe14da4b12853726 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Sat, 19 Apr 2025 02:08:30 -0400 Subject: [PATCH] Ownership for a short lifetime string. --- dpi/hello.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/dpi/hello.cc b/dpi/hello.cc index b88ff96..dc325a2 100644 --- a/dpi/hello.cc +++ b/dpi/hello.cc @@ -37,7 +37,7 @@ int main(void) { FILE *in_stream; Dsh *sh; - char *dpip_tag, *cmd = NULL, *url = NULL, *child_cmd = NULL; + char *dpip_tag, *cmd = NULL, *url = NULL; char *esc_tag, *d_cmd; size_t n; int ret; @@ -150,11 +150,11 @@ int main(void) * (An example of generating dynamic content with an external * program). */ if (cmd && url) { - child_cmd = dStrdup("date -R"); - MSG("[%s]\n", child_cmd); + std::string child_cmd = "date -R"; + MSG("[%s]\n", child_cmd.c_str()); /* Fork, exec command, get its output and answer */ - if ((in_stream = popen(child_cmd, "r")) == NULL) { + if ((in_stream = popen(child_cmd.c_str(), "r")) == NULL) { perror("popen"); return EXIT_FAILURE; } @@ -171,8 +171,6 @@ int main(void) if ((ret = pclose(in_stream)) != 0) MSG("popen: [%d]\n", ret); - - dFree(child_cmd); } a_Dpip_dsh_write_str(sh, 1, "\n");