SQLite4
Check-in [3f6924e784]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Use sqlite4_malloc instead of malloc in test fixture for num
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 3f6924e784fc9bdc4f946f73376338608eeb9c50
User & Date: peterreid 2013-10-26 12:44:09
Context
2013-10-26
19:58
Begin adding code to make the log file circular. check-in: ec6dda0ade user: dan tags: trunk
12:44
Use sqlite4_malloc instead of malloc in test fixture for num check-in: 3f6924e784 user: peterreid tags: trunk
2013-10-25
20:20
Add start of checkpointing code to btree. check-in: 29373a8844 user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/test_num.c.

11
12
13
14
15
16
17

18
19
20
21
22
23
24
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
...
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
*************************************************************************
** Code for testing the sqlite4_num_xxx() functions used by SQLite for
** base 10 arithmatic.
*/

#include "sqlite4.h"
#include <tcl.h>


#define NUM_FORMAT "sign:%d approx:%d e:%d m:%llu"

/* Append a return value representing a sqlite4_num.
*/
static void append_num_result( Tcl_Interp *interp, sqlite4_num A ){
  char buf[100];
................................................................................
    if( strchr(argv[3], 'b') ) encoding = SQLITE4_UTF16BE; 
    if( strchr(argv[3], 'l') ) encoding = SQLITE4_UTF16LE; 
  }
  
 if( encoding==SQLITE4_UTF16BE || encoding==SQLITE4_UTF16LE ){
    flags |= encoding;
    input_len = strlen(argv[1]); 
    utf16_text = malloc(2*(input_len+1));
    if( !utf16_text ){
      Tcl_AppendResult(interp, "utf16 string allocation failed");
      return TCL_ERROR;
    }
    for( i=0; i<2*(input_len+1); i++ ){
      utf16_text[i] = 0;
    }
................................................................................
  }else{
    text = argv[1];
  }

  A = sqlite4_num_from_text(text, len, flags, 0);
  append_num_result(interp, A);
  if( utf16_text ){
    free(utf16_text);
  }
  return TCL_OK;
}

static int test_num_text_is_real(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */







>







 







|







 







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
...
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
*************************************************************************
** Code for testing the sqlite4_num_xxx() functions used by SQLite for
** base 10 arithmatic.
*/

#include "sqlite4.h"
#include <tcl.h>
#include <string.h>

#define NUM_FORMAT "sign:%d approx:%d e:%d m:%llu"

/* Append a return value representing a sqlite4_num.
*/
static void append_num_result( Tcl_Interp *interp, sqlite4_num A ){
  char buf[100];
................................................................................
    if( strchr(argv[3], 'b') ) encoding = SQLITE4_UTF16BE; 
    if( strchr(argv[3], 'l') ) encoding = SQLITE4_UTF16LE; 
  }
  
 if( encoding==SQLITE4_UTF16BE || encoding==SQLITE4_UTF16LE ){
    flags |= encoding;
    input_len = strlen(argv[1]); 
    utf16_text = sqlite4_malloc(0, 2*(input_len+1));
    if( !utf16_text ){
      Tcl_AppendResult(interp, "utf16 string allocation failed");
      return TCL_ERROR;
    }
    for( i=0; i<2*(input_len+1); i++ ){
      utf16_text[i] = 0;
    }
................................................................................
  }else{
    text = argv[1];
  }

  A = sqlite4_num_from_text(text, len, flags, 0);
  append_num_result(interp, A);
  if( utf16_text ){
    sqlite4_free(0, utf16_text);
  }
  return TCL_OK;
}

static int test_num_text_is_real(
  void *NotUsed,
  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */