lavf/protocols: avoid discarding const in avio_enum_protocols()

Instead of storing the protocol pointer in the opaque iteration state,
store just the index of the next protocol, similarly to how
ff_urlcontext_child_class_iterate() works.
This commit is contained in:
Anton Khirnov 2021-11-25 15:40:16 +01:00
parent c0e46ad9a9
commit 6ebaccf327
1 changed files with 9 additions and 9 deletions

View File

@ -93,17 +93,17 @@ const AVClass *ff_urlcontext_child_class_iterate(void **iter)
const char *avio_enum_protocols(void **opaque, int output) const char *avio_enum_protocols(void **opaque, int output)
{ {
const URLProtocol **p = *opaque; uintptr_t i;
p = p ? p + 1 : url_protocols; for (i = (uintptr_t)*opaque; url_protocols[i]; i++) {
*opaque = p; const URLProtocol *p = url_protocols[i];
if (!*p) { if ((output && p->url_write) || (!output && p->url_read)) {
*opaque = NULL; *opaque = (void*)(uintptr_t)(i + 1);
return NULL; return p->name;
}
} }
if ((output && (*p)->url_write) || (!output && (*p)->url_read)) *opaque = NULL;
return (*p)->name; return NULL;
return avio_enum_protocols(opaque, output);
} }
const AVClass *avio_protocol_get_class(const char *name) const AVClass *avio_protocol_get_class(const char *name)