]> granicus.if.org Git - curl/commit
gtls: fix build when sizeof(long) < sizeof(void *)
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 26 Jun 2017 21:15:22 +0000 (23:15 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 3 Jul 2017 13:45:25 +0000 (15:45 +0200)
commitc0cdc68c7eacaa4fda3e2324f8618b6bbe038983
treed1b191bc2d7800a89f8be851ced14f76e2b4bb5e
parent3a48a132685ca891ce1b7a10bbcd4b4cd33cee5e
gtls: fix build when sizeof(long) < sizeof(void *)

- Change gnutls pointer/int macros to pointer/curl_socket_t.
  Prior to this change they used long type as well.

The size of the `long` data type can be shorter than that of pointer
types. This is the case most notably on Windows.

If C99 were acceptable, we could simply use `intptr_t` here. But we
want to retain C89 compatibility.

Simply use the trick of performing pointer arithmetic with the NULL
pointer: to convert an integer `i` to a pointer, simply take the
address of the `i`th element of a hypothetical character array
starting at address NULL. To convert back, simply cast the pointer
difference.

Thanks to Jay Satiro for the initial modification to use curl_socket_t
instead of int/long.

Closes #1617

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
lib/vtls/gtls.c