Hi Charles,
I tested the patch you forwarded and it was nonfunctional. It attempted to
construct a two-dimensional array "D" of dimensions (M+1 x N+1) like so:

*   D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ;
**   D  = &D_buf ;
*


This compiles, but doesn't work. There is no way to allocate a 2D matrix
dynamically by only using malloc. To do the proper pointer arithmetic the
D[row][col] operators used later in this source need to know at least one
dimension of the matrix. This is known for static arrays, but not for
dynamic arrays. The patch you forwarded always leads to a memory access
error.

I implemented my own patch that handles the 2D pointer arithmetic in a small
wrapper class. This new version is tested and dynamically allocates the
memory, so it should fit your needs. You can find the new version of the
"annotate.cc" file here:

http://mummer.cvs.sourceforge.net/viewvc/mummer/MUMmer/src/tigr/annotate.cc?revision=1.3&view=markup

This is included in a new MUMmer release (v3.22) I cut last week.

Best,
-Adam


On Sun, Aug 2, 2009 at 12:07 AM, Charles Plessy <[email protected]> wrote:

> Le Thu, Jul 30, 2009 at 03:25:53PM -0400, Adam Phillippy a écrit :
> >    This patch looks fine. I saw it awhile back, but it got lost in the
> >    shuffle and was never applied.  I'm on vacation right now, but I'll
> apply
> >    it to our distribution when I return.
>
> Thank you very much. In the meantime, an improved version was prepared by
> Boyd
> Stephen Smith Jr. I updated our subversion repository accordingly, and you
> can
> retreive it with the following link:
>
>
> http://svn.debian.org/wsvn/debian-med/trunk/packages/mummer/trunk/debian/patches/01sm_src_tigr.diff
>
> The difference with the previous patch is the following:
>
>    int  Errors, Tmp;
>    long int  i, j, Ct;
>
> -   assert ( D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ) ;
> +   assert ( SIZE_MAX / (M+1) >= (N+1) ) ;
> +   D_buf  = (int  *) calloc ( (M+1)*(N+1), sizeof(int) ) ;
> +   assert ( D_buf ) ;
>    D  = &D_buf ;
> -   assert ( Op_buf = (char *) calloc ( (M+1)*(N+1), sizeof(char) ) ) ;
> +   Op_buf = (char *) calloc ( (M+1)*(N+1), sizeof(char) ) ;
> +   assert ( Op_buf ) ;
>    Op = &Op_buf ;
> -   assert ( Show_A = (char *) calloc ( 2*(M+1) , sizeof(char) ) ) ;
> -   assert ( Show_B = (char *) calloc ( 2*(N+1) , sizeof(char) ) ) ;
> +
> +   assert ( SIZE_MAX >> 1 >= (M+1) ) ;
> +   Show_A = (char *) calloc ( 2*(M+1) , sizeof(char) ) ;
> +   assert ( Show_A ) ;
> +   Show_B = (char *) calloc ( 2*(N+1) , sizeof(char) ) ;
> +   assert ( Show_B ) ;
>
>    D [0] [0] = 0;
>    Op [0] [0] = 'a';
>
> Have a nice vacation !
>
> --
> Charles Plessy
> Debian Med packaging team,
> http://www.debian.org/devel/debian-med
> Tsurumi, Kanagawa, Japan
>

Reply via email to