Re: problem passing pointer array



On Jun 30, 10:00 pm, vipps...@xxxxxxxxx wrote:

You also don't check the return value of malloc. It could be NULL, in
which case you just return; the caller can check for the
successfulness of create_ptr_list(a, &b, c, &d); with if(b !=
NULL) ...

Also the design is flawed, mainly because this works only for arrays
of ints, and because 40 is hardcoded, how about you change this to
struct vector { size_t nmemb, size; void *elements; };
struct vector *remove_if(const struct vector *v, int (*remove)(void
*));

though I don't like the 'remove_if' name, I chose it because there's a
similar function in common lisp named REMOVE-IF.

Well, I wrote the function just as a test function to understand about
array of pointers. Just chose int to make things simple.
.



Relevant Pages

  • Re: Design issue and Synthesis problem
    ... design too scalable and in that process, adding many arrays and thus ... assignments, but I cannot find any missing assignments. ... generates a multiplexer (and two adders). ...
    (comp.lang.verilog)
  • Re: Whats the deal with PSoC programmers?
    ... MCU with partially reconfigurable ... requiring processing of slowly varying analog signals. ... The reconfigurable arrays are loaded at reset time with configuration ... Cypress's design tools. ...
    (comp.arch.fpga)
  • Re: [9fans] A new language for Plan 9
    ... I'm aware of that quote. ... The design of bit arrays will be totally different from the design of bitfields. ... and then use getlong as follows: ...
    (comp.os.plan9)
  • Re: [patch 7/8] fdmap v2 - implement sys_socket2
    ... expects their fds to be compact (for many reasons - they use select, ... use them to index 0-based arrays, etc...), and if the kernel suddendly ... So I believe that the correct way is that the caller specifically selects ...
    (Linux-Kernel)
  • Re: why cant functions return arrays
    ... would make it not a mistake in design for no good reason (per Jacob), ... but a consequence of how arrays are handled by the rest of the ... language" is a mistake in design or not is an open issue. ... reason weren't about to store and pass dope vectors. ...
    (comp.lang.c)