]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/base64.c
Fastbuf: fbmulti: fixes from MJ
[libucw.git] / ucw / base64.c
index 9865f4c60c5c1a4101a0252d1def151d47112f1e..f50e48eb1ecdf1d65eb53974c142eb09a15f34d2 100644 (file)
@@ -9,8 +9,9 @@
 
 #undef LOCAL_DEBUG
 
 
 #undef LOCAL_DEBUG
 
-#include "ucw/lib.h"
-#include "ucw/base64.h"
+#include <ucw/lib.h>
+#include <ucw/base64.h>
+#include <ucw/threads.h>
 
 #include <string.h>
 
 
 #include <string.h>
 
@@ -67,16 +68,17 @@ base64_decode(byte *dest, const byte *src, uns len)
        static uns table_built = 0;
 
        if (table_built == 0) {
        static uns table_built = 0;
 
        if (table_built == 0) {
-               byte *chp;
-               table_built = 1;
+               ucwlib_lock();
                for(ch = 0; ch < 256; ch++) {
                for(ch = 0; ch < 256; ch++) {
-                       chp = strchr(base64_table, ch);
+                       byte *chp = strchr(base64_table, ch);
                        if(chp) {
                                reverse_table[ch] = chp - base64_table;
                        } else {
                                reverse_table[ch] = 0xff;
                        }
                }
                        if(chp) {
                                reverse_table[ch] = chp - base64_table;
                        } else {
                                reverse_table[ch] = 0xff;
                        }
                }
+               table_built = 1;
+               ucwlib_unlock();
        }
 
        /* run through the whole string, converting as we go */
        }
 
        /* run through the whole string, converting as we go */