- char* libname = strndup(map_basename.c_str(), match.rm_so);
-
- // Strip the version suffix:
- if (libname && not regexec(&res->version_re, libname, 1, &match, 0)) {
- char* temp = libname;
- libname = strndup(temp, match.rm_so);
- free(temp);
+ // Strip the version suffix:
+ if (std::regex_search(libname, match, version_re))
+ libname = match.prefix();