On Tuesday 22 July 2008 22:02, L. Gabriel Somlo wrote:
> On Sun, Jul 20, 2008 at 08:55:46PM +0200, Denys Vlasenko wrote:
> > You need to just minimize usage of globals. IOW: use them
> > when it is _noticeably_ more difficult to not do so.
> 
> turning the hash into a linked list wasn't that hard, and while in
> theory it could be slower, in practice that shouldn't make a real
> difference.

Hm.

+static struct prg_node {
+       struct prg_node *next;
+       int inode;
+       char name[PROGNAME_WIDTH];
+} *prg_list = NULL;
+
+static int flag_prg = 0;


It still has these statics. I explained how to get rid of them:

On Sunday 20 July 2008 20:55, Denys Vlasenko wrote:
> You need to just minimize usage of globals. IOW: use them
> when it is _noticeably_ more difficult to not do so.
> 
> And then, when you have just a few globals, use "G trick".
> See, for example, crontab.c:
> 
> struct globals {
>         unsigned LogLevel; /* = 8; */
>         const char *LogFile;
>         const char *CDir; /* = CRONTABS; */
>         CronFile *FileBase;
> #if SETENV_LEAKS
>         char *env_var_user;
>         char *env_var_home;
> #endif
> };
> #define G (*(struct globals*)&bb_common_bufsiz1)
> #define LogLevel           (G.LogLevel               )
> #define LogFile            (G.LogFile                )
> #define CDir               (G.CDir                   )
> #define FileBase           (G.FileBase               )
> #define env_var_user       (G.env_var_user           )
> #define env_var_home       (G.env_var_home           )
> #define INIT_G() do { \
>         LogLevel = 8; \
>         CDir = CRONTABS; \
> } while (0)
> 
> ...
> 
> int crond_main(...)
> {
>         unsigned opt;
> 
>         INIT_G();
> ...

Can you do it?
--
vda
_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to