/ Check-in [cb1876d8]
Login

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

Overview
Comment:Use a new algorithm for sqlite3Strlen that is slightly slower but is more like to work on a mixture of 32- and 64-bit systems. Ticket #3237, #3248. (CVS 5471)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: cb1876d8dc102be74be98dd57ac14ee67be8e8e2
User & Date: drh 2008-07-24 17:06:48
Context
2008-07-24
23:34
Reduce the size of the parser allocation. Add additional instrumentation to mem2. speed1*.test uses scratch malloc. (CVS 5472) check-in: 599a9dea user: drh tags: trunk
17:06
Use a new algorithm for sqlite3Strlen that is slightly slower but is more like to work on a mixture of 32- and 64-bit systems. Ticket #3237, #3248. (CVS 5471) check-in: cb1876d8 user: drh tags: trunk
15:50
Update the implementation of sqlite3ResultSetOfSelect() to (hopefully) make it clearer that malloc failures cannot possibly result in a crash. Ticket #3247. (CVS 5470) check-in: 74553109 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/util.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
52
53
54
55
56
57
58


59


60
61
62
63
64
65
66
67
68
69
70
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.239 2008/07/22 05:15:53 shane Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>


/*
................................................................................

/*
** Return the length of a string, except do not allow the string length
** to exceed the SQLITE_LIMIT_LENGTH setting.
*/
int sqlite3Strlen(sqlite3 *db, const char *z){
  const char *z2 = z;


  while( *z2 ){ z2++; }


  if( z2 > &z[db->aLimit[SQLITE_LIMIT_LENGTH]] ){
    return db->aLimit[SQLITE_LIMIT_LENGTH];
  }else{
    return (int)(z2 - z);
  }
}

/*
** Set the most recent error code and error string for the sqlite
** handle "db". The error code is set to "err_code".
**







|







 







>
>

>
>
|


|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
..
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.240 2008/07/24 17:06:48 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>


/*
................................................................................

/*
** Return the length of a string, except do not allow the string length
** to exceed the SQLITE_LIMIT_LENGTH setting.
*/
int sqlite3Strlen(sqlite3 *db, const char *z){
  const char *z2 = z;
  int len;
  size_t x;
  while( *z2 ){ z2++; }
  x = z2 - z;
  len = 0x7fffffff & x;
  if( len!=x || len > db->aLimit[SQLITE_LIMIT_LENGTH] ){
    return db->aLimit[SQLITE_LIMIT_LENGTH];
  }else{
    return len;
  }
}

/*
** Set the most recent error code and error string for the sqlite
** handle "db". The error code is set to "err_code".
**