mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-09 14:21:03 +03:00
Half-way through a major refactoring of the memory allocation.
I have not even attempted to compile so I am certain there are countless errors. (CVS 4231) FossilOrigin-Name: deb7ecd65f7b83eaf0ba610eeef3b0ede61db1c3
This commit is contained in:
37
src/util.c
37
src/util.c
@@ -14,7 +14,7 @@
|
||||
** This file contains functions for allocating memory, comparing
|
||||
** strings, and stuff like that.
|
||||
**
|
||||
** $Id: util.c,v 1.207 2007/06/26 00:37:28 drh Exp $
|
||||
** $Id: util.c,v 1.208 2007/08/16 04:30:40 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -631,13 +631,13 @@ static int hexToInt(int h){
|
||||
** binary value has been obtained from malloc and must be freed by
|
||||
** the calling routine.
|
||||
*/
|
||||
void *sqlite3HexToBlob(const char *z){
|
||||
void *sqlite3HexToBlob(sqlite3 *db, const char *z){
|
||||
char *zBlob;
|
||||
int i;
|
||||
int n = strlen(z);
|
||||
if( n%2 ) return 0;
|
||||
|
||||
zBlob = (char *)sqliteMalloc(n/2);
|
||||
zBlob = (char *)sqlite3DbMallocRaw(db, n/2);
|
||||
if( zBlob ){
|
||||
for(i=0; i<n; i+=2){
|
||||
zBlob[i/2] = (hexToInt(z[i])<<4) | hexToInt(z[i+1]);
|
||||
@@ -699,34 +699,3 @@ int sqlite3SafetyOff(sqlite3 *db){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a pointer to the ThreadData associated with the calling thread.
|
||||
*/
|
||||
ThreadData *sqlite3ThreadData(){
|
||||
ThreadData *p = (ThreadData*)sqlite3OsThreadSpecificData(1);
|
||||
if( !p ){
|
||||
sqlite3FailedMalloc();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
** Return a pointer to the ThreadData associated with the calling thread.
|
||||
** If no ThreadData has been allocated to this thread yet, return a pointer
|
||||
** to a substitute ThreadData structure that is all zeros.
|
||||
*/
|
||||
const ThreadData *sqlite3ThreadDataReadOnly(){
|
||||
static const ThreadData zeroData = {0}; /* Initializer to silence warnings
|
||||
** from broken compilers */
|
||||
const ThreadData *pTd = sqlite3OsThreadSpecificData(0);
|
||||
return pTd ? pTd : &zeroData;
|
||||
}
|
||||
|
||||
/*
|
||||
** Check to see if the ThreadData for this thread is all zero. If it
|
||||
** is, then deallocate it.
|
||||
*/
|
||||
void sqlite3ReleaseThreadData(){
|
||||
sqlite3OsThreadSpecificData(-1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user