cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Unable to send the image file.

From: Anil J <anilj.mailing_at_gmail.com>
Date: Tue, 16 Apr 2013 15:39:44 -0400

Thanks a lot folks for your comments. I incorporated all the comments.
However the real problem was in the getting the file size for buffer
allocation. After seeking to the end of the file, I was not setting the
file pointer back to the start. This was causing the just allocation of the
memory block, but no real data getting copied into it.

After adding "fseek(fp, 0L, SEEK_SET);" it is now working perfect.

Thanks once again!

/anil.

On Tue, Apr 16, 2013 at 8:36 AM, Tor Arntsen <kspt.tor_at_gmail.com> wrote:

> > Le 2013-04-16 07:17, Anil J a écrit :
> >> buffer = (char *)malloc(fileLen + 1);
>
> Also, don't cast malloc(). It returns a void* which is compatible with
> all pointers.
> Casting the return from malloc() isn't only unnecessary, it can hide
> errors.
> If you get a message without the cast it simply means you've forgotten to
> #include <stdlib.h>
>
> -Tor
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-04-16