[PATCH 2 of 4 v2] mpatch: shuffle stuff around so it's easier to make a cffi version of mpatch

Yuya Nishihara yuya at tcha.org
Mon Jun 27 09:54:24 EDT 2016


On Thu, 23 Jun 2016 08:57:09 +0200, Maciej Fijalkowski wrote:
> # HG changeset patch
> # User Maciej Fijalkowski <fijall at gmail.com>
> # Date 1465303444 -7200
> #      Tue Jun 07 14:44:04 2016 +0200
> # Node ID f5a166fffae1ade1e5b7bcad759a3899813bd91f
> # Parent  d62df3ee14e3b2cf658c247233bda60def219e0f
> mpatch: shuffle stuff around so it's easier to make a cffi version of mpatch

> +static struct flist *lalloc(ssize_t size)

IIRC, ssize_t is available only on posix environment. We'll need typedef for
Windows.

> -static struct flist *decode(const char *bin, Py_ssize_t len)
> +int decode(const char *bin, ssize_t len, struct flist** res)
>  {
>  	struct flist *l;
>  	struct frag *lt;
> @@ -208,7 +195,7 @@
>  	/* assume worst case size, we won't have many of these lists */
>  	l = lalloc(len / 12 + 1);
>  	if (!l)
> -		return NULL;
> +		return MPATCH_ERR_NO_MEM;

It would greatly help reviewing patches if error handling changes were
made in a separate patch.

> +int decode(const char *bin, ssize_t len, struct flist** res);
> +struct flist *combine(struct flist *a, struct flist *b);
> +ssize_t calcsize(ssize_t len, struct flist *l);
> +void lfree(struct flist *a);
> +int apply(char *buf, const char *orig, ssize_t len, struct flist *l);
> +ssize_t _patchedsize(long orig, char* bin, ssize_t patchlen);
> +struct flist *fold(void *bins, struct flist* (*get_next_item)(void*, ssize_t),
> +	               ssize_t start, ssize_t end);

I'm not sure if we can export these functions without a risk of name
conflicts.


More information about the Mercurial-devel mailing list