[GRASS-dev] r.flow with barrier fails

Helena Mitasova hmitaso at unity.ncsu.edu
Wed Feb 21 00:42:03 EST 2007


On Feb 20, 2007, at 3:36 AM, Brad Douglas wrote:

> On Tue, 2007-02-20 at 08:53 +0100, Jáchym Čepický wrote:
>> hi glynn,
>>
>> 2007/2/19, Glynn Clements <glynn at gclements.plus.com>:
>>>> [...]
>>> Probably this:
>>>
>>> --- raster/r.flow/io.c  7 Feb 2007 05:24:40 -0000       1.14
>>> +++ raster/r.flow/io.c  19 Feb 2007 18:18:41 -0000
>>> @@ -126,7 +126,7 @@
>>>             for (col = 0; col < region.cols; col++)
>>>             {
>>>                 BM_set(bitbar, col, row, (barc[col] != 0));
>>> -               if (barc[col] != 0)
>>> +               if (ds.buf && barc[col] != 0)
>>>                     put(ds, row, col, -1);
>>>             }
>>>         }
>>
>> This makes it not to segfault, but it does not make r.flow work  
>> properly
>
> The problem is that it requires that the 'dsout' option be  
> specified in
> addition to the options you already provided.  The memory buffer is  
> not
> allocated without it.
>
> I'm not sure if that's a feature or a bug.

It is a bug. I have never run it  with the barrier option after it  
was rewritten
so I did not know that it does not work. I will try to look at it but  
I don't have
much time now.

Helena

> If someone can guide me to
> proper operation, I'll commit fix for it.
>
> Here's a patch that "corrects" the problem (essentially, what Glynn
> already posted), but I'm not sure if this is proper behavior.   
> Ideally,
> it should either A) error out or B) allocate the memory if 'barin' is
> specified:
>
> RCS file: /grassrepository/grass6/raster/r.flow/io.c,v
> retrieving revision 1.14
> diff -u -r1.14 io.c
> --- io.c        7 Feb 2007 05:24:40 -0000       1.14
> +++ io.c        20 Feb 2007 08:30:36 -0000
> @@ -114,7 +114,7 @@
>         G_close_cell(fd);
>      }
>
> -    if (parm.barin)
> +    if (parm.barin && parm.dsout)
>      {
>          G_message(_("Reading input files: barrier"));
>         barc = G_allocate_d_raster_buf();
> @@ -132,6 +132,8 @@
>         }
>         G_close_cell(fd);
>      }
> +
> +    if (barc) G_free (barc);
>  }
>
>
> -- 
> Brad Douglas <rez touchofmadness com>                    KB8UYR/6
> Address: 37.493,-121.924 / WGS84    National Map Corps #TNMC-3785
>





More information about the grass-dev mailing list