[GRASS5] Re: r.flow calloc error

Helena hmitaso at unity.ncsu.edu
Thu Jun 30 23:41:33 EDT 2005


I have disabled the offset parameter which was not having
much of the desired effect (dispersal of flow on convex areas).
There is still a bug in computation of 3D length of a flowline (2D length works) -
something is wrong in the code below but I must admit that I dont
quite understand the following line (280 in calc.c)

if (parm.lgout)
             *l += parm.l3d ? hypot(length, oldz - p->z) : length;
return 1;

This is not a serious bug because 2D length should be sufficient for
most applications except for cases with steep terrain and low resolution.

Everything else seems to be running fine now (no G_calloc error).

Helena




Markus Neteler wrote:
> helena,
> 
> I was taking a look at r.flow and discovered that I
> get an unwanted error:
> 
> r.flow help
> r.flow Version 13 August 1995, update/fix October 1999
> 
> FEHLER: G_calloc: out of memory
> 
> Looking into the code, I see:
> 
> io.c, line 127
> 
>     default_offset = 0.0; /* fixed 20. May 2001 Helena */
>     default_offset_ans = (char *) G_calloc((int) log10( default_offset) + 2,
>                                            sizeof (char));
>     sprintf (default_offset_ans, "%f", default_offset);
>     offset_opt = (char *) G_calloc((int) log10( default_offset) + 4,
>                                    sizeof (char));
> 
> 
> AFAIK, log10(0.0) is always INF, which will then crash. 
> Should it be log10(double)?
> 
> See you tomorrow
> 
>  Markus
> 





More information about the grass-dev mailing list