diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-29 17:55:28 -0800 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2012-02-29 17:55:28 -0800 |
commit | 72da14e414061f8884f3a94ebdf54d52739fba0a (patch) | |
tree | 4cef06db39f73f2b59e2ce08512cabec1a142f9d /common.cpp | |
parent | 8ada404c5f1ec068a8bad144b63878d9962aa1f0 (diff) |
Fix a leak
Diffstat (limited to 'common.cpp')
-rw-r--r-- | common.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -559,9 +559,6 @@ wcstring wsetlocale(int category, const wchar_t *locale) if (locale && wcscmp(locale,L"")){ lang = wcs2str( locale ); } - { - lang = NULL; - } char * res = setlocale(category,lang); free( lang ); @@ -661,6 +658,15 @@ ssize_t write_loop(int fd, const char *buff, size_t count) return out_cum; } +ssize_t read_loop(int fd, void *buff, size_t count) +{ + ssize_t result; + do { + result = read(fd, buff, count); + } while (result < 0 && (errno == EAGAIN || errno == EINTR)); + return result; +} + void debug( int level, const wchar_t *msg, ... ) { va_list va; @@ -743,12 +749,12 @@ void format_int_safe(char buff[128], int val) { val = -val; while (val > 0) { - buff[idx++] = val % 10; + buff[idx++] = '0' + (val % 10); val /= 10; } if (negative) buff[idx++] = '-'; - buff[idx++] = 0; + buff[idx] = 0; size_t left = 0, right = idx - 1; while (left < right) { |