1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-09 14:21:03 +03:00

Eliminate all uses of sprintf() and strcpy(). These were not being

misused.  But getting rid of them removes a library dependency.  And
it avoids warnings from the OpenBSD compiler.  Ticket #2336. (CVS 3916)

FossilOrigin-Name: ba4845b32bdf38e623c4f7246e6e327715bbba4b
This commit is contained in:
drh
2007-05-04 13:15:55 +00:00
parent 92d4d7a92e
commit 5bb3eb9b9a
23 changed files with 204 additions and 162 deletions

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.199 2007/04/06 02:32:34 drh Exp $
** $Id: util.c,v 1.200 2007/05/04 13:15:56 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -424,7 +424,7 @@ int sqlite3OutstandingMallocs(Tcl_Interp *interp){
z = &zAlloc[TESTALLOC_OFFSET_STACK(p)];
for(i=0; i<TESTALLOC_STACKFRAMES; i++){
char zHex[128];
sprintf(zHex, "%p", ((void **)z)[i]);
sqlite3_snprintf(sizeof(zHex), zHex, "%p", ((void **)z)[i]);
Tcl_ListObjAppendElement(0, pStack, Tcl_NewStringObj(zHex, -1));
}
@@ -722,9 +722,11 @@ int sqlite3AllocSize(void *p){
*/
char *sqlite3StrDup(const char *z){
char *zNew;
int n;
if( z==0 ) return 0;
zNew = sqlite3MallocRaw(strlen(z)+1, 1);
if( zNew ) strcpy(zNew, z);
n = strlen(z)+1;
zNew = sqlite3MallocRaw(n, 1);
if( zNew ) memcpy(zNew, z, n);
return zNew;
}
char *sqlite3StrNDup(const char *z, int n){
@@ -766,9 +768,11 @@ void sqlite3SetString(char **pz, ...){
*zResult = 0;
va_start(ap, pz);
while( (z = va_arg(ap, const char*))!=0 ){
strcpy(zResult, z);
zResult += strlen(zResult);
int n = strlen(z);
memcpy(zResult, z, n);
zResult += n;
}
zResult[0] = 0;
va_end(ap);
}