There is an opportunity for a minor speedup in sqlite3Malloc().

sqlite3Malloc() is implemented as follows:

void *sqlite3Malloc(int n){
    void *p;
    if( (p = malloc(n))==0 ){
        if( n>0 ) sqlite3_malloc_failed++;
    }else{
        memset(p, 0, n);
    }
    return p;
}

The separation of the malloc() from the memset() is potentially ineffecient. If available, sqlite3Malloc() should use calloc() instead. Specifically:

void *sqlite3Malloc(int n){
    void *p;
    if( (p = calloc(n, 1))==0 ){
        if( n>0 ) sqlite3_malloc_failed++;
    }
    return p;
}

Better yet, why zero the memory at all?

Reply via email to