On Aug 26 2007 15:28, Denys Vlasenko wrote: >> > >> > What exactely would using kcalloc() over kzalloc() here buy us? >> >> technically, nothing. > >The idea of calloc is that it can check for underflow in parameter. Actually, overflow. calloc(0xFFFF0000, 0x1000) => will return NULL malloc(0xFFFF0000 * 0x1000) => silent 32 bit multiplication/truncation, will allocate less than requested. >calloc(-1, 10000000) => easy to detect >malloc(-1 * 10000000) => malloc(-10000000) => not so trivial Jan -- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
- Follow-Ups:
- Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- From: "Jesper Juhl" <jesper.juhl@gmail.com>
- Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- References:
- [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects()
- From: Jesper Juhl <jesper.juhl@gmail.com>
- Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- From: "Jesper Juhl" <jesper.juhl@gmail.com>
- Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- From: "Robert P. J. Day" <rpjday@mindspring.com>
- Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- From: Denys Vlasenko <vda.linux@googlemail.com>
- [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects()
- Prev by Date: Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- Next by Date: Slow, persistent memory leak in 2.6.20
- Previous by thread: Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- Next by thread: Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
- Index(es):
![]() |