[Groonga-commit] groonga/groonga [master] Ensure reserving needed space

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Feb 14 18:55:52 JST 2013


Kouhei Sutou	2013-02-14 18:55:52 +0900 (Thu, 14 Feb 2013)

  New Revision: 97a46f55a84322f9ff4f1cab4c51c1270af52bae
  https://github.com/groonga/groonga/commit/97a46f55a84322f9ff4f1cab4c51c1270af52bae

  Log:
    Ensure reserving needed space

  Modified files:
    lib/str.c

  Modified: lib/str.c (+7 -2)
===================================================================
--- lib/str.c    2013-02-13 23:50:19 +0900 (8be6dbe)
+++ lib/str.c    2013-02-14 18:55:52 +0900 (cc9fd67)
@@ -2058,8 +2058,13 @@ grn_text_ulltoa(grn_ctx *ctx, grn_obj *buf, unsigned long long int i)
 inline static void
 ftoa_(grn_ctx *ctx, grn_obj *buf, double d)
 {
-  char *curr = GRN_BULK_CURR(buf);
-  size_t len = sprintf(curr, "%#.15g", d);
+  char *curr;
+  size_t len;
+#define DIGIT_NUMBER 15
+  grn_bulk_reserve(ctx, buf, DIGIT_NUMBER + 1);
+  curr = GRN_BULK_CURR(buf);
+  len = sprintf(curr, "%#.*g", DIGIT_NUMBER, d);
+#undef DIGIT_NUMBER
   if (curr[len - 1] == '.') {
     GRN_BULK_INCR_LEN(buf, len);
     GRN_TEXT_PUTC(ctx, buf, '0');
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index