c
typedef struct {
    jpc_stream_t *stream;
    bool is_owned;
} jpc_stream_owned_t;

jpc_stream_owned_t jpc_streamlist_remove_owned(jpc_streamlist_t *list, int idx) {
    jpc_stream_t *stream = jpc_streamlist_remove(list, idx);
    return (jpc_stream_owned_t){stream, stream != NULL};
}

// In the main function:
jpc_stream_owned_t owned_stream = jpc_streamlist_remove_owned(dec->pkthdrstreams, 0);
if (!owned_stream.is_owned) {
    return -1;
}
tile->pkthdrstream = owned_stream.stream;
