diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-09-18 00:50:22 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-09-18 00:50:22 +0400 |
commit | 66a679d71f15b8c6b0ba4e1c8895ef1824b93a56 (patch) | |
tree | 9ca3086f7efa3560dfae8ab4c6c25f3ffbc7a415 /source/blender/blenlib/intern/fileops.c | |
parent | e07b807357a4667db5de02df1e8f6b27775ca389 (diff) |
i18n: replace gnu unifont with droid sans font
- Static variables can be initialized with constants only.
- Removed bunifont.ttf.c from datafiles -- it's not actually a
data file. Unicode font loading stuff is not in blenkernel/font.c
- Allocate as much memory for unzipped data as it's needed.
Default read chunk is 512Kb.
- Fixed regression (or just a typo) in setting utf locale.
- Default locale set to en_US:en works fine now.
- Commented put Nepali language in user preferences -- it's
not supported by current droid font and imo it's better to
have nice font for languages we actually have translation for
rather than allowing to choose more languages in user preferences.
Diffstat (limited to 'source/blender/blenlib/intern/fileops.c')
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index 7c2b9f03c60..6b125435b31 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -52,6 +52,8 @@ #include <sys/param.h> #endif +#include "MEM_guardedalloc.h" + #include "BLI_blenlib.h" #include "BKE_utildefines.h" @@ -107,18 +109,39 @@ int BLI_gzip(const char *from, const char *to) { /* gzip the file in from_file and write it to memery to_mem, at most size bytes. return the unziped size */ -int BLI_ungzip_to_mem(const char *from_file, char *to_mem, const int size) +char *BLI_ungzip_to_mem(const char *from_file, int *size_r) { gzFile gzfile; - int readsize; + int readsize, size, alloc_size=0; + char *mem= NULL; + const int chunk_size= 512*1024; + + size= 0; gzfile = gzopen( from_file, "rb" ); - readsize = gzread( gzfile, to_mem, size); - if (readsize < 0) - readsize = EOF; + for(;;) { + if(mem==NULL) { + mem= MEM_callocN(chunk_size, "BLI_ungzip_to_mem"); + alloc_size= chunk_size; + } else { + mem= MEM_reallocN(mem, size+chunk_size); + alloc_size+= chunk_size; + } + + readsize= gzread(gzfile, mem+size, chunk_size); + if(readsize>0) { + size+= readsize; + } + else break; + } + + if(mem && alloc_size!=size) + mem= MEM_reallocN(mem, size); + + *size_r= size; - return readsize; + return mem; } |