Skip to main content
14 events
when toggle format what by license comment
Jul 15, 2019 at 16:08 comment added mlp In C, do not cast the result of a call to malloc(), realloc(), or calloc() - it is unnecessary and potentially hides the serious error of a missing prototype.
Oct 31, 2017 at 3:08 answer added Louis T timeline score: 25
May 23, 2015 at 16:05 review Close votes
May 27, 2015 at 0:02
May 23, 2015 at 15:43 comment added chappjc possible duplicate of Why does cudaMalloc() use pointer to pointer?
Nov 16, 2011 at 2:05 vote accept smilingbuddha
Nov 3, 2011 at 12:31 comment added R.. GitHub STOP HELPING ICE Violating the principle of least astonishment is a much smaller offense than requiring temp void *'s all over the place. The int *error could be null when the user does not care about the reason. Actually I see no reason allocation could fail other than "out of memory" (and more importantly no reason the caller could care why it failed), so it's probably just a design mistake to begin with.
Nov 3, 2011 at 12:09 answer added jwdmsd timeline score: 11
Nov 3, 2011 at 11:58 comment added ArchaeaSoftware @R.: you get credit for offering an alternative at the same time you criticize the API - most API critics winge without proposing alternatives - but unless you believe that every CUDA runtime call should take an additional int * to pass back an error code, (which would make for a much more cluttered and difficult-to-use API), your alternative proposal is not orthogonal and violates the principle of least astonishment.
Nov 3, 2011 at 8:15 answer added flolo timeline score: 1
Nov 3, 2011 at 7:19 answer added CygnusX1 timeline score: 30
Nov 3, 2011 at 2:59 comment added R.. GitHub STOP HELPING ICE @Hans: It's still a horrible API design. Instead, it should take an extra int *error argument to store the error code, which will be valid when the return value is a null pointer. As-is, the design negates all benefits of void pointers and requires you to jump through hoops to use the function correctly.
Nov 3, 2011 at 2:57 answer added R.. GitHub STOP HELPING ICE timeline score: 28
Nov 3, 2011 at 0:57 comment added Hans Passant Because it returns an error code that tells you why it failed. Returning a null pointer on failure, like malloc(), is a poor substitute for an error code, doesn't mean anything more than "it didn't work". You are supposed to check it.
Nov 3, 2011 at 0:37 history asked smilingbuddha CC BY-SA 3.0