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'; |