User: Password:
Subscribe / Log in / New account

Fear of the void

Fear of the void

Posted Jun 22, 2004 12:46 UTC (Tue) by steve_rotolo (guest, #15915)
Parent article: Fear of the void

Consider the following interface:

struct funky; // forward decl

struct funky * funky_alloc (void);

void funky_dealloc (struct funky *);

int funky_dowhatever (struct funky *);

No magic, just C. The structure is private. All the user sees is pointers but the pointers are typed so the compiler can do the "magic" checking. Keep it simple.

(Log in to post comments)

Fear of the void

Posted Sep 11, 2004 9:34 UTC (Sat) by jbglaw (guest, #10406) [Link]

This adds a lot of bloat. First, you introduce an own alloc and free function for each used struct. And further more, you completely break what was intended: to check pointers that were passed along from generic subsystem code. These are shipped as void * pointers, and void * always "works" with other non-void pointers...

Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds