Use less error prone string list, map or multimap pointer types

Use pointers to incomplete struct types. If an argument of a not suitable
type is passed to a function of any string collection,
C compiler will warn:
  warning: passing argument 1 of <func> from incompatible pointer type
C++ compiler will raise an error, for example:
  error: cannot convert 'cef_string_list_t' ... to 'cef_string_multimap_t'

With the previously used `void*` pointer types, such errors in a code were not
diagnosed.
This commit is contained in:
Sergey Markelov
2023-04-13 16:06:02 +00:00
committed by Marshall Greenblatt
parent f90d5bc49e
commit c3648f42b2
6 changed files with 7 additions and 7 deletions

View File

@@ -13,7 +13,7 @@ using StringList = std::vector<CefString>;
} // namespace
CEF_EXPORT cef_string_list_t cef_string_list_alloc() {
return new StringList;
return reinterpret_cast<cef_string_list_t>(new StringList);
}
CEF_EXPORT size_t cef_string_list_size(cef_string_list_t list) {
@@ -58,5 +58,5 @@ CEF_EXPORT void cef_string_list_free(cef_string_list_t list) {
CEF_EXPORT cef_string_list_t cef_string_list_copy(cef_string_list_t list) {
DCHECK(list);
StringList* impl = reinterpret_cast<StringList*>(list);
return new StringList(*impl);
return reinterpret_cast<cef_string_list_t>(new StringList(*impl));
}