From: Matthew Fernandez Date: Sun, 26 Jun 2022 19:10:34 +0000 (-0700) Subject: gvplugin_load: use a 'strview_t' for 'reqpkg' X-Git-Tag: 5.0.0~9^2~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eec916ebc4f8823bf3f1bd2c434b7e16861b9bfb;p=graphviz gvplugin_load: use a 'strview_t' for 'reqpkg' This string is always terminated by `'\0'`, not `':'`, so there is little advantage in using a `strview_t` over a `const char*`. But upcoming changes will refactor the surrounding code to use `strview_t`, so it will be more readable to use `strview_t` consistently here. --- diff --git a/lib/gvc/gvplugin.c b/lib/gvc/gvplugin.c index c53975a23..c26beadc4 100644 --- a/lib/gvc/gvplugin.c +++ b/lib/gvc/gvplugin.c @@ -272,14 +272,14 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) const char *reqdep_end = NULL; size_t reqdep_len = 0; - const char *reqpkg = NULL; + strview_t reqpkg = {NULL}; if (reqtyp_end != NULL) { reqdep = reqtyp_end + strlen(":"); reqdep_end = strchr(reqdep, ':'); if (reqdep_end != NULL) { reqdep_len = (size_t)(reqdep_end - reqdep); - reqpkg = reqdep_end + strlen(":"); + reqpkg = strview(reqdep_end + strlen(":"), '\0'); } else { reqdep_len = strlen(reqdep); } @@ -301,7 +301,7 @@ gvplugin_available_t *gvplugin_load(GVC_t * gvc, api_t api, const char *str) continue; /* dependencies not empty, but mismatched */ } } - if (!reqpkg || strcmp(reqpkg, pnext->package->name) == 0) { + if (!reqpkg.data || strview_str_eq(reqpkg, pnext->package->name)) { // found with no packagename constraints, or with required matching packagename if (dep && apidep != api) /* load dependency if needed, continue if can't find */