freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: christos AT zoulas.com (Christos Zoulas)
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] Patch proposal
- Date: Thu, 16 Jun 2011 18:16:27 -0400
On Jun 16, 4:01pm, freddy77 AT gmail.com (Frediano Ziglio) wrote:
-- Subject: Re: [freetds] Patch proposal
| 2011/6/16 Christos Zoulas <christos AT zoulas.com>:
| > On Jun 16, Â 9:32am, freddy77 AT gmail.com (Frediano Ziglio) wrote:
| > -- Subject: [freetds] Patch proposal
| >
| > | Hi,
| > | Â I would like to include this patch (and follows). It define some
| > | macro to merge allocation and casting.
| >
| > Please do not cast malloc. We are not in the 80's anymore and casting
| > malloc() hides bugs. For example on an _LP64 bit machine casting malloc()
| > will hide the warning of integer to pointer conversion when there is no
| > prototype in scope.
| >
| > christos
|
| integer ?? No Christos these macros just convert the void* pointer to
| a specialized pointer. Just lika a C++ "new int[10]" return a int* a
| tds_zallocn(int, 10) will return a int*.
It does not need to to return the specialized type. You only need the
cast in c++, and this is what "void *" was created for.
This cast hides bugs though (unless you are using gcc which warns anyway):
$ cat foo.c
int
main(void)
{
char *p = (char *)malloc(100000000);
printf("%p\n", p);
return 0;
}
$ cc foo.c
$ ./a.out
0x7d9d1010
$ cat foo.c
#include <stdlib.h>
int
main(void)
{
char *p = (char *)malloc(100000000);
printf("%p\n", p);
return 0;
}
$ cc foo.c
$ ./a.out
0x2b07d8720010
christos
-
[freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
-
Re: [freetds] Patch proposal,
Christos Zoulas, 06/16/2011
-
Re: [freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
- Re: [freetds] Patch proposal, Christos Zoulas, 06/16/2011
-
Re: [freetds] Patch proposal,
Frediano Ziglio, 06/16/2011
-
Re: [freetds] Patch proposal,
jklowden, 06/16/2011
- Re: [freetds] Patch proposal, Frediano Ziglio, 06/17/2011
-
Re: [freetds] Patch proposal,
Christos Zoulas, 06/16/2011
Archive powered by MHonArc 2.6.24.