src/printf.c

changeset 812
fda0f1910d7e
parent 811
b02ad05c7f2d
child 813
aba6d37b78bd
equal deleted inserted replaced
811:b02ad05c7f2d 812:fda0f1910d7e
106 s.length = 0; 106 s.length = 0;
107 char buf[CX_PRINTF_SBO_SIZE]; 107 char buf[CX_PRINTF_SBO_SIZE];
108 va_list ap2; 108 va_list ap2;
109 va_copy(ap2, ap); 109 va_copy(ap2, ap);
110 int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap); 110 int ret = vsnprintf(buf, CX_PRINTF_SBO_SIZE, fmt, ap);
111 if (ret > 0 && ret < CX_PRINTF_SBO_SIZE) { 111 if (ret >= 0 && ret < CX_PRINTF_SBO_SIZE) {
112 s.ptr = cxMalloc(a, ret + 1); 112 s.ptr = cxMalloc(a, ret + 1);
113 if (s.ptr) { 113 if (s.ptr) {
114 s.length = (size_t) ret; 114 s.length = (size_t) ret;
115 memcpy(s.ptr, buf, ret); 115 memcpy(s.ptr, buf, ret);
116 s.ptr[s.length] = '\0'; 116 s.ptr[s.length] = '\0';

mercurial