Of course, you noticed that it should also really really be...

if (!fgets(tmpline, MAX_LINE_SIZE, instream))
    break;

"Aaron Stone" <[EMAIL PROTECTED]> said:

> Actually we're both wrong!
> 
> if (!fgets(tmpline, MAX_LINE_SIZE, instream);
>     break;
> 
> Because fgets returns NULL for an empty line, tmpline's memory is lost.
> 
> I'm putting together more patches and will post them to the SourceForge site
> this evening. BTW - do you mind GNU GCC extensions? I quickly implemented the
> db_get_result_...() functions (there's u64, int and bool versions) as macros
> like so:
> 
>                                                                              
>                       #define db_get_result_int(row, field) \
>         ({ \
>                 char *tmp; \
>                 tmp = db_get_result(row, field); \
>                 ( tmp ? atoi(tmp) : 0 ); \
>         })
> #define db_get_result_bool(row, field) \
>         ({ \
>                 char *tmp; \
>                 tmp = db_get_result(row, field); \
>                 ( tmp ? ( atoi(tmp) ? 1 : 0 ) : 0 ); \
>         })
> #define db_get_result_u64(row, field) \
>         ({ \
>                 char *tmp; \
>                 tmp = db_get_result(row, field); \
>                 ( tmp ? strtoull(tmp, NULL, 10) : 0 ); \
>         })
> 
> 
> ({ expression; expression; expression; }) is a GNU extension that takes on the
> value of the last expression in the block. Lazy stuff. If you'd rather see
> these done as functions, it's two seconds work to move them into db.c
> 
> Aaron
> 
> 
> Ilja Booij <[EMAIL PROTECTED]> said: [snipped the whole thing]
> 
> > tmpline = fgets(tmpline, MAX_LINE_SIZE, instream);
> > if (!tmpline)
> >     break;
> 
> 
> --
> _______________________________________________
> Dbmail-dev mailing list
> Dbmail-dev@dbmail.org
> http://twister.fastxs.net/mailman/listinfo/dbmail-dev
> 



-- 



Reply via email to