cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Example httpcustomheader.c is showing bad practice/is buggy

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 5 Aug 2015 14:20:22 +0200 (CEST)

On Wed, 5 Aug 2015, Wolfgang Petroschka wrote:

> I understand that this is a simple example. But I feel that a lot of people
> get started copying and pasting example code and then modify it for their
> needs.

Yeah, we have that constant battle between readability to show the concepts
and actually writing good and proper code.

Several, if not most, of the examples take shortcuts and avoid error checks in
order to get more compact and focus on the APIs and function calls that are
involved and they are too lax and sloppy on checking return codes and error
conditions to bail out and to not leak memory or crash on NULL pointer
dereferences.

Feel free to improve this example to what you think it should be and we can
discuss / merge that. We of course want users to learn to do the right thing.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2015-08-05