On Thu, Aug 21, 2025 at 7:42 PM Christ van Willegen <[email protected]>
wrote:
>
> +/*
> + * "items(blob)" function
> + * Converts a Blob into a List of [index, byte] pairs.
> + * Caller must have already checked that argvars[0] is a Blob.
> + * A null blob behaves like an empty blob.
> + */
> + void
> +blob2items(typval_T *argvars, typval_T *rettv)
> +{
> + blob_T *blob = argvars[0].vval.v_blob;
> +
> + if (rettv_list_alloc(rettv) == FAIL)
> + return;
> +
> + for (int i = 0; i < blob_len(blob); i++)
> + {
> + list_T *l2 = list_alloc();
> + if (l2 == NULL)
> + return;
>
>
> Memory leak rettv?
>
>
No. This function is expected to set rettv to a List. In case of failure,
this will return an empty List.
This is the same as how other types (List, Dict, Tuple, String) are
handled. The returned List
will be freed later.
> +
> + if (list_append_list(rettv->vval.v_list, l2) == FAIL)
> + {
> + vim_free(l2);
> + return;
> + }
> +
> + if (list_append_number(l2, i) == FAIL
> + || list_append_number(l2, blob_get(blob, i)) == FAIL)
> + return;
>
>
> Memory leak l2?
>
>
No. The list l2 is already added to rettv.
Regards,
Yegappan
>
> + }
> +}
>
>
>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/vim_dev/CAAW7x7nckxnctDzDdt2fZubCtZw6chnXYJEjxPBFC-GyKqWpNw%40mail.gmail.com.