[PATCH] eliminate des.c static buffers (resend)

Denis Vlasenko vda.linux at googlemail.com
Thu Jul 5 00:45:34 UTC 2007

Hi Mike,

des.c has by far the biggest static buffers in entire uclibc - 70k,
which is bad for NOMMU.

These two patches eliminate buffers in statically allocated data section
and allocate them on first use using malloc.

This has a drawback that malloc can fail and we segfault.
(however, in this case static buffers won't work also - program simply
will fail to load - ENOMEM).

Since uclibc has more places where we may want to convert static
buffers into dynamically-allocated-on-first-use ones,
we can deal with malloc failure priblem by having specialized
__uc_malloc which provides user callback on malloc failure
(a pointer of user function to call, etc) and concerned users
can hook on that callback.

Attached patch #1 moves some static variables into des_init(),
since they are only used there and there's no reason to keep them

Second patch is moving all non-constant data into malloc space.
Only two pointer variables remain in data section.

Please apply first patch as it seems to be trivially correct,
and consider applying second one too.

If you don't like second patch, please let me know why.


   text    data     bss     dec     hex filename
   4091       0   70760   74851   12463 uClibc.t0/libcrypt/des.o
   4151       0   70240   74391   12297 uClibc.t1/libcrypt/des.o
   4501       0       8    4509    119d uClibc.t3/libcrypt/des.o

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1.patch
Type: text/x-diff
Size: 1063 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20070705/075c7cad/attachment-0004.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2.patch
Type: text/x-diff
Size: 5425 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/uclibc/attachments/20070705/075c7cad/attachment-0005.bin 

More information about the uClibc mailing list