Fossil SCM
Replace all malloc() calls with fossil_malloc(). The fossil_malloc() routine panics rather than return a NULL pointer.
Commit
8f41b2fa75f930893dca27e5574e0e8bc0f65fe0
Parent
59f685856bb6a1b…
22 files changed
+1
-1
+2
-4
+3
-3
+2
-4
+1
-1
+4
-8
+1
-2
+3
-12
+7
-11
+2
-4
+2
-4
+1
-1
+18
+8
-11
+1
-1
+3
-4
+1
-2
+1
-1
+1
-4
+1
-4
+1
-4
+1
-1
~
src/bag.c
~
src/blob.c
~
src/captcha.c
~
src/cgi.c
~
src/checkin.c
~
src/content.c
~
src/delta.c
~
src/diff.c
~
src/encode.c
~
src/graph.c
~
src/http_transport.c
~
src/login.c
~
src/main.c
~
src/manifest.c
~
src/pqueue.c
~
src/printf.c
~
src/search.c
~
src/th_main.c
~
src/tkt.c
~
src/wikiformat.c
~
src/winhttp.c
~
src/zip.c
+1
-1
| --- src/bag.c | ||
| +++ src/bag.c | ||
| @@ -86,11 +86,11 @@ | ||
| 86 | 86 | int nDel = 0; /* Number of deleted entries */ |
| 87 | 87 | int nLive = 0; /* Number of live entries */ |
| 88 | 88 | |
| 89 | 89 | old = *p; |
| 90 | 90 | assert( newSize>old.cnt ); |
| 91 | - p->a = malloc( sizeof(p->a[0])*newSize ); | |
| 91 | + p->a = fossil_malloc( sizeof(p->a[0])*newSize ); | |
| 92 | 92 | p->sz = newSize; |
| 93 | 93 | memset(p->a, 0, sizeof(p->a[0])*newSize ); |
| 94 | 94 | for(i=0; i<old.sz; i++){ |
| 95 | 95 | int e = old.a[i]; |
| 96 | 96 | if( e>0 ){ |
| 97 | 97 |
| --- src/bag.c | |
| +++ src/bag.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | int nDel = 0; /* Number of deleted entries */ |
| 87 | int nLive = 0; /* Number of live entries */ |
| 88 | |
| 89 | old = *p; |
| 90 | assert( newSize>old.cnt ); |
| 91 | p->a = malloc( sizeof(p->a[0])*newSize ); |
| 92 | p->sz = newSize; |
| 93 | memset(p->a, 0, sizeof(p->a[0])*newSize ); |
| 94 | for(i=0; i<old.sz; i++){ |
| 95 | int e = old.a[i]; |
| 96 | if( e>0 ){ |
| 97 |
| --- src/bag.c | |
| +++ src/bag.c | |
| @@ -86,11 +86,11 @@ | |
| 86 | int nDel = 0; /* Number of deleted entries */ |
| 87 | int nLive = 0; /* Number of live entries */ |
| 88 | |
| 89 | old = *p; |
| 90 | assert( newSize>old.cnt ); |
| 91 | p->a = fossil_malloc( sizeof(p->a[0])*newSize ); |
| 92 | p->sz = newSize; |
| 93 | memset(p->a, 0, sizeof(p->a[0])*newSize ); |
| 94 | for(i=0; i<old.sz; i++){ |
| 95 | int e = old.a[i]; |
| 96 | if( e>0 ){ |
| 97 |
+2
-4
| --- src/blob.c | ||
| +++ src/blob.c | ||
| @@ -136,12 +136,11 @@ | ||
| 136 | 136 | pBlob->aData = 0; |
| 137 | 137 | pBlob->nAlloc = 0; |
| 138 | 138 | pBlob->nUsed = 0; |
| 139 | 139 | pBlob->iCursor = 0; |
| 140 | 140 | }else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){ |
| 141 | - char *pNew = realloc(pBlob->aData, newSize); | |
| 142 | - if( pNew==0 ) blob_panic(); | |
| 141 | + char *pNew = fossil_realloc(pBlob->aData, newSize); | |
| 143 | 142 | pBlob->aData = pNew; |
| 144 | 143 | pBlob->nAlloc = newSize; |
| 145 | 144 | if( pBlob->nUsed>pBlob->nAlloc ){ |
| 146 | 145 | pBlob->nUsed = pBlob->nAlloc; |
| 147 | 146 | } |
| @@ -162,12 +161,11 @@ | ||
| 162 | 161 | */ |
| 163 | 162 | static void blobReallocStatic(Blob *pBlob, unsigned int newSize){ |
| 164 | 163 | if( newSize==0 ){ |
| 165 | 164 | *pBlob = empty_blob; |
| 166 | 165 | }else{ |
| 167 | - char *pNew = malloc( newSize ); | |
| 168 | - if( pNew==0 ) blob_panic(); | |
| 166 | + char *pNew = fossil_malloc( newSize ); | |
| 169 | 167 | if( pBlob->nUsed>newSize ) pBlob->nUsed = newSize; |
| 170 | 168 | memcpy(pNew, pBlob->aData, pBlob->nUsed); |
| 171 | 169 | pBlob->aData = pNew; |
| 172 | 170 | pBlob->xRealloc = blobReallocMalloc; |
| 173 | 171 | pBlob->nAlloc = newSize; |
| 174 | 172 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -136,12 +136,11 @@ | |
| 136 | pBlob->aData = 0; |
| 137 | pBlob->nAlloc = 0; |
| 138 | pBlob->nUsed = 0; |
| 139 | pBlob->iCursor = 0; |
| 140 | }else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){ |
| 141 | char *pNew = realloc(pBlob->aData, newSize); |
| 142 | if( pNew==0 ) blob_panic(); |
| 143 | pBlob->aData = pNew; |
| 144 | pBlob->nAlloc = newSize; |
| 145 | if( pBlob->nUsed>pBlob->nAlloc ){ |
| 146 | pBlob->nUsed = pBlob->nAlloc; |
| 147 | } |
| @@ -162,12 +161,11 @@ | |
| 162 | */ |
| 163 | static void blobReallocStatic(Blob *pBlob, unsigned int newSize){ |
| 164 | if( newSize==0 ){ |
| 165 | *pBlob = empty_blob; |
| 166 | }else{ |
| 167 | char *pNew = malloc( newSize ); |
| 168 | if( pNew==0 ) blob_panic(); |
| 169 | if( pBlob->nUsed>newSize ) pBlob->nUsed = newSize; |
| 170 | memcpy(pNew, pBlob->aData, pBlob->nUsed); |
| 171 | pBlob->aData = pNew; |
| 172 | pBlob->xRealloc = blobReallocMalloc; |
| 173 | pBlob->nAlloc = newSize; |
| 174 |
| --- src/blob.c | |
| +++ src/blob.c | |
| @@ -136,12 +136,11 @@ | |
| 136 | pBlob->aData = 0; |
| 137 | pBlob->nAlloc = 0; |
| 138 | pBlob->nUsed = 0; |
| 139 | pBlob->iCursor = 0; |
| 140 | }else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){ |
| 141 | char *pNew = fossil_realloc(pBlob->aData, newSize); |
| 142 | pBlob->aData = pNew; |
| 143 | pBlob->nAlloc = newSize; |
| 144 | if( pBlob->nUsed>pBlob->nAlloc ){ |
| 145 | pBlob->nUsed = pBlob->nAlloc; |
| 146 | } |
| @@ -162,12 +161,11 @@ | |
| 161 | */ |
| 162 | static void blobReallocStatic(Blob *pBlob, unsigned int newSize){ |
| 163 | if( newSize==0 ){ |
| 164 | *pBlob = empty_blob; |
| 165 | }else{ |
| 166 | char *pNew = fossil_malloc( newSize ); |
| 167 | if( pBlob->nUsed>newSize ) pBlob->nUsed = newSize; |
| 168 | memcpy(pNew, pBlob->aData, pBlob->nUsed); |
| 169 | pBlob->aData = pNew; |
| 170 | pBlob->xRealloc = blobReallocMalloc; |
| 171 | pBlob->nAlloc = newSize; |
| 172 |
+3
-3
| --- src/captcha.c | ||
| +++ src/captcha.c | ||
| @@ -69,11 +69,11 @@ | ||
| 69 | 69 | ** Render an 8-character hexadecimal string as ascii art. |
| 70 | 70 | ** Space to hold the result is obtained from malloc() and should be freed |
| 71 | 71 | ** by the caller. |
| 72 | 72 | */ |
| 73 | 73 | char *captcha_render(const char *zPw){ |
| 74 | - char *z = malloc( 500 ); | |
| 74 | + char *z = fossil_malloc( 500 ); | |
| 75 | 75 | int i, j, k, m; |
| 76 | 76 | |
| 77 | 77 | k = 0; |
| 78 | 78 | for(i=0; i<6; i++){ |
| 79 | 79 | for(j=0; j<8; j++){ |
| @@ -202,11 +202,11 @@ | ||
| 202 | 202 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 203 | 203 | ** Space to hold the result is obtained from malloc() and should be freed |
| 204 | 204 | ** by the caller. |
| 205 | 205 | */ |
| 206 | 206 | char *captcha_render(const char *zPw){ |
| 207 | - char *z = malloc( 300 ); | |
| 207 | + char *z = fossil_malloc( 300 ); | |
| 208 | 208 | int i, j, k, m; |
| 209 | 209 | const char *zChar; |
| 210 | 210 | |
| 211 | 211 | k = 0; |
| 212 | 212 | for(i=0; i<4; i++){ |
| @@ -359,11 +359,11 @@ | ||
| 359 | 359 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 360 | 360 | ** Space to hold the result is obtained from malloc() and should be freed |
| 361 | 361 | ** by the caller. |
| 362 | 362 | */ |
| 363 | 363 | char *captcha_render(const char *zPw){ |
| 364 | - char *z = malloc( 600 ); | |
| 364 | + char *z = fossil_malloc( 600 ); | |
| 365 | 365 | int i, j, k, m; |
| 366 | 366 | const char *zChar; |
| 367 | 367 | |
| 368 | 368 | k = 0; |
| 369 | 369 | for(i=0; i<6; i++){ |
| 370 | 370 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -69,11 +69,11 @@ | |
| 69 | ** Render an 8-character hexadecimal string as ascii art. |
| 70 | ** Space to hold the result is obtained from malloc() and should be freed |
| 71 | ** by the caller. |
| 72 | */ |
| 73 | char *captcha_render(const char *zPw){ |
| 74 | char *z = malloc( 500 ); |
| 75 | int i, j, k, m; |
| 76 | |
| 77 | k = 0; |
| 78 | for(i=0; i<6; i++){ |
| 79 | for(j=0; j<8; j++){ |
| @@ -202,11 +202,11 @@ | |
| 202 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 203 | ** Space to hold the result is obtained from malloc() and should be freed |
| 204 | ** by the caller. |
| 205 | */ |
| 206 | char *captcha_render(const char *zPw){ |
| 207 | char *z = malloc( 300 ); |
| 208 | int i, j, k, m; |
| 209 | const char *zChar; |
| 210 | |
| 211 | k = 0; |
| 212 | for(i=0; i<4; i++){ |
| @@ -359,11 +359,11 @@ | |
| 359 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 360 | ** Space to hold the result is obtained from malloc() and should be freed |
| 361 | ** by the caller. |
| 362 | */ |
| 363 | char *captcha_render(const char *zPw){ |
| 364 | char *z = malloc( 600 ); |
| 365 | int i, j, k, m; |
| 366 | const char *zChar; |
| 367 | |
| 368 | k = 0; |
| 369 | for(i=0; i<6; i++){ |
| 370 |
| --- src/captcha.c | |
| +++ src/captcha.c | |
| @@ -69,11 +69,11 @@ | |
| 69 | ** Render an 8-character hexadecimal string as ascii art. |
| 70 | ** Space to hold the result is obtained from malloc() and should be freed |
| 71 | ** by the caller. |
| 72 | */ |
| 73 | char *captcha_render(const char *zPw){ |
| 74 | char *z = fossil_malloc( 500 ); |
| 75 | int i, j, k, m; |
| 76 | |
| 77 | k = 0; |
| 78 | for(i=0; i<6; i++){ |
| 79 | for(j=0; j<8; j++){ |
| @@ -202,11 +202,11 @@ | |
| 202 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 203 | ** Space to hold the result is obtained from malloc() and should be freed |
| 204 | ** by the caller. |
| 205 | */ |
| 206 | char *captcha_render(const char *zPw){ |
| 207 | char *z = fossil_malloc( 300 ); |
| 208 | int i, j, k, m; |
| 209 | const char *zChar; |
| 210 | |
| 211 | k = 0; |
| 212 | for(i=0; i<4; i++){ |
| @@ -359,11 +359,11 @@ | |
| 359 | ** Render an 8-digit hexadecimal string as ascii arg. |
| 360 | ** Space to hold the result is obtained from malloc() and should be freed |
| 361 | ** by the caller. |
| 362 | */ |
| 363 | char *captcha_render(const char *zPw){ |
| 364 | char *z = fossil_malloc( 600 ); |
| 365 | int i, j, k, m; |
| 366 | const char *zChar; |
| 367 | |
| 368 | k = 0; |
| 369 | for(i=0; i<6; i++){ |
| 370 |
+2
-4
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -387,12 +387,11 @@ | ||
| 387 | 387 | ** deallocated after this routine returns. |
| 388 | 388 | */ |
| 389 | 389 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 390 | 390 | if( nAllocQP<=nUsedQP ){ |
| 391 | 391 | nAllocQP = nAllocQP*2 + 10; |
| 392 | - aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); | |
| 393 | - if( aParamQP==0 ) fossil_exit(1); | |
| 392 | + aParamQP = fossil_realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); | |
| 394 | 393 | } |
| 395 | 394 | aParamQP[nUsedQP].zName = zName; |
| 396 | 395 | aParamQP[nUsedQP].zValue = zValue; |
| 397 | 396 | if( g.fHttpTrace ){ |
| 398 | 397 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -681,12 +680,11 @@ | ||
| 681 | 680 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 682 | 681 | if( len>0 && zType ){ |
| 683 | 682 | blob_zero(&g.cgiIn); |
| 684 | 683 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 685 | 684 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 686 | - z = malloc( len+1 ); | |
| 687 | - if( z==0 ) fossil_exit(1); | |
| 685 | + z = fossil_malloc( len+1 ); | |
| 688 | 686 | len = fread(z, 1, len, g.httpIn); |
| 689 | 687 | z[len] = 0; |
| 690 | 688 | if( zType[0]=='a' ){ |
| 691 | 689 | add_param_list(z, '&'); |
| 692 | 690 | }else{ |
| 693 | 691 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -387,12 +387,11 @@ | |
| 387 | ** deallocated after this routine returns. |
| 388 | */ |
| 389 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 390 | if( nAllocQP<=nUsedQP ){ |
| 391 | nAllocQP = nAllocQP*2 + 10; |
| 392 | aParamQP = realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); |
| 393 | if( aParamQP==0 ) fossil_exit(1); |
| 394 | } |
| 395 | aParamQP[nUsedQP].zName = zName; |
| 396 | aParamQP[nUsedQP].zValue = zValue; |
| 397 | if( g.fHttpTrace ){ |
| 398 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -681,12 +680,11 @@ | |
| 681 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 682 | if( len>0 && zType ){ |
| 683 | blob_zero(&g.cgiIn); |
| 684 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 685 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 686 | z = malloc( len+1 ); |
| 687 | if( z==0 ) fossil_exit(1); |
| 688 | len = fread(z, 1, len, g.httpIn); |
| 689 | z[len] = 0; |
| 690 | if( zType[0]=='a' ){ |
| 691 | add_param_list(z, '&'); |
| 692 | }else{ |
| 693 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -387,12 +387,11 @@ | |
| 387 | ** deallocated after this routine returns. |
| 388 | */ |
| 389 | void cgi_set_parameter_nocopy(const char *zName, const char *zValue){ |
| 390 | if( nAllocQP<=nUsedQP ){ |
| 391 | nAllocQP = nAllocQP*2 + 10; |
| 392 | aParamQP = fossil_realloc( aParamQP, nAllocQP*sizeof(aParamQP[0]) ); |
| 393 | } |
| 394 | aParamQP[nUsedQP].zName = zName; |
| 395 | aParamQP[nUsedQP].zValue = zValue; |
| 396 | if( g.fHttpTrace ){ |
| 397 | fprintf(stderr, "# cgi: %s = [%s]\n", zName, zValue); |
| @@ -681,12 +680,11 @@ | |
| 680 | g.zContentType = zType = P("CONTENT_TYPE"); |
| 681 | if( len>0 && zType ){ |
| 682 | blob_zero(&g.cgiIn); |
| 683 | if( strcmp(zType,"application/x-www-form-urlencoded")==0 |
| 684 | || strncmp(zType,"multipart/form-data",19)==0 ){ |
| 685 | z = fossil_malloc( len+1 ); |
| 686 | len = fread(z, 1, len, g.httpIn); |
| 687 | z[len] = 0; |
| 688 | if( zType[0]=='a' ){ |
| 689 | add_param_list(z, '&'); |
| 690 | }else{ |
| 691 |
+1
-1
| --- src/checkin.c | ||
| +++ src/checkin.c | ||
| @@ -461,11 +461,11 @@ | ||
| 461 | 461 | void select_commit_files(void){ |
| 462 | 462 | if( g.argc>2 ){ |
| 463 | 463 | int ii; |
| 464 | 464 | Blob b; |
| 465 | 465 | blob_zero(&b); |
| 466 | - g.aCommitFile = malloc(sizeof(int)*(g.argc-1)); | |
| 466 | + g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1)); | |
| 467 | 467 | |
| 468 | 468 | for(ii=2; ii<g.argc; ii++){ |
| 469 | 469 | int iId; |
| 470 | 470 | file_tree_name(g.argv[ii], &b, 1); |
| 471 | 471 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 472 | 472 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -461,11 +461,11 @@ | |
| 461 | void select_commit_files(void){ |
| 462 | if( g.argc>2 ){ |
| 463 | int ii; |
| 464 | Blob b; |
| 465 | blob_zero(&b); |
| 466 | g.aCommitFile = malloc(sizeof(int)*(g.argc-1)); |
| 467 | |
| 468 | for(ii=2; ii<g.argc; ii++){ |
| 469 | int iId; |
| 470 | file_tree_name(g.argv[ii], &b, 1); |
| 471 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 472 |
| --- src/checkin.c | |
| +++ src/checkin.c | |
| @@ -461,11 +461,11 @@ | |
| 461 | void select_commit_files(void){ |
| 462 | if( g.argc>2 ){ |
| 463 | int ii; |
| 464 | Blob b; |
| 465 | blob_zero(&b); |
| 466 | g.aCommitFile = fossil_malloc(sizeof(int)*(g.argc-1)); |
| 467 | |
| 468 | for(ii=2; ii<g.argc; ii++){ |
| 469 | int iId; |
| 470 | file_tree_name(g.argv[ii], &b, 1); |
| 471 | iId = db_int(-1, "SELECT id FROM vfile WHERE pathname=%Q", blob_str(&b)); |
| 472 |
+4
-8
| --- src/content.c | ||
| +++ src/content.c | ||
| @@ -80,13 +80,12 @@ | ||
| 80 | 80 | if( contentCache.n>500 || contentCache.szTotal>50000000 ){ |
| 81 | 81 | content_cache_expire_oldest(); |
| 82 | 82 | } |
| 83 | 83 | if( contentCache.n>=contentCache.nAlloc ){ |
| 84 | 84 | contentCache.nAlloc = contentCache.nAlloc*2 + 10; |
| 85 | - contentCache.a = realloc(contentCache.a, | |
| 85 | + contentCache.a = fossil_realloc(contentCache.a, | |
| 86 | 86 | contentCache.nAlloc*sizeof(contentCache.a[0])); |
| 87 | - if( contentCache.a==0 ) fossil_panic("out of memory"); | |
| 88 | 87 | } |
| 89 | 88 | p = &contentCache.a[contentCache.n++]; |
| 90 | 89 | p->rid = rid; |
| 91 | 90 | p->age = contentCache.nextAge++; |
| 92 | 91 | contentCache.szTotal += blob_size(pBlob); |
| @@ -240,22 +239,20 @@ | ||
| 240 | 239 | int nAlloc = 10; |
| 241 | 240 | int *a = 0; |
| 242 | 241 | int mx; |
| 243 | 242 | Blob delta, next; |
| 244 | 243 | |
| 245 | - a = malloc( sizeof(a[0])*nAlloc ); | |
| 246 | - if( a==0 ) fossil_panic("out of memory"); | |
| 244 | + a = fossil_malloc( sizeof(a[0])*nAlloc ); | |
| 247 | 245 | a[0] = rid; |
| 248 | 246 | a[1] = nextRid; |
| 249 | 247 | n = 1; |
| 250 | 248 | while( !bag_find(&contentCache.inCache, nextRid) |
| 251 | 249 | && (nextRid = findSrcid(nextRid))>0 ){ |
| 252 | 250 | n++; |
| 253 | 251 | if( n>=nAlloc ){ |
| 254 | 252 | nAlloc = nAlloc*2 + 10; |
| 255 | - a = realloc(a, nAlloc*sizeof(a[0])); | |
| 256 | - if( a==0 ) fossil_panic("out of memory"); | |
| 253 | + a = fossil_realloc(a, nAlloc*sizeof(a[0])); | |
| 257 | 254 | } |
| 258 | 255 | a[n] = nextRid; |
| 259 | 256 | } |
| 260 | 257 | mx = n; |
| 261 | 258 | rc = content_get(a[n], pBlob); |
| @@ -350,12 +347,11 @@ | ||
| 350 | 347 | db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 351 | 348 | while( db_step(&q)==SQLITE_ROW ){ |
| 352 | 349 | int child = db_column_int(&q, 0); |
| 353 | 350 | if( nChildUsed>=nChildAlloc ){ |
| 354 | 351 | nChildAlloc = nChildAlloc*2 + 10; |
| 355 | - aChild = realloc(aChild, nChildAlloc*sizeof(aChild)); | |
| 356 | - if( aChild==0 ) fossil_panic("out of memory"); | |
| 352 | + aChild = fossil_realloc(aChild, nChildAlloc*sizeof(aChild)); | |
| 357 | 353 | } |
| 358 | 354 | aChild[nChildUsed++] = child; |
| 359 | 355 | } |
| 360 | 356 | db_finalize(&q); |
| 361 | 357 | for(i=1; i<nChildUsed; i++){ |
| 362 | 358 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -80,13 +80,12 @@ | |
| 80 | if( contentCache.n>500 || contentCache.szTotal>50000000 ){ |
| 81 | content_cache_expire_oldest(); |
| 82 | } |
| 83 | if( contentCache.n>=contentCache.nAlloc ){ |
| 84 | contentCache.nAlloc = contentCache.nAlloc*2 + 10; |
| 85 | contentCache.a = realloc(contentCache.a, |
| 86 | contentCache.nAlloc*sizeof(contentCache.a[0])); |
| 87 | if( contentCache.a==0 ) fossil_panic("out of memory"); |
| 88 | } |
| 89 | p = &contentCache.a[contentCache.n++]; |
| 90 | p->rid = rid; |
| 91 | p->age = contentCache.nextAge++; |
| 92 | contentCache.szTotal += blob_size(pBlob); |
| @@ -240,22 +239,20 @@ | |
| 240 | int nAlloc = 10; |
| 241 | int *a = 0; |
| 242 | int mx; |
| 243 | Blob delta, next; |
| 244 | |
| 245 | a = malloc( sizeof(a[0])*nAlloc ); |
| 246 | if( a==0 ) fossil_panic("out of memory"); |
| 247 | a[0] = rid; |
| 248 | a[1] = nextRid; |
| 249 | n = 1; |
| 250 | while( !bag_find(&contentCache.inCache, nextRid) |
| 251 | && (nextRid = findSrcid(nextRid))>0 ){ |
| 252 | n++; |
| 253 | if( n>=nAlloc ){ |
| 254 | nAlloc = nAlloc*2 + 10; |
| 255 | a = realloc(a, nAlloc*sizeof(a[0])); |
| 256 | if( a==0 ) fossil_panic("out of memory"); |
| 257 | } |
| 258 | a[n] = nextRid; |
| 259 | } |
| 260 | mx = n; |
| 261 | rc = content_get(a[n], pBlob); |
| @@ -350,12 +347,11 @@ | |
| 350 | db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 351 | while( db_step(&q)==SQLITE_ROW ){ |
| 352 | int child = db_column_int(&q, 0); |
| 353 | if( nChildUsed>=nChildAlloc ){ |
| 354 | nChildAlloc = nChildAlloc*2 + 10; |
| 355 | aChild = realloc(aChild, nChildAlloc*sizeof(aChild)); |
| 356 | if( aChild==0 ) fossil_panic("out of memory"); |
| 357 | } |
| 358 | aChild[nChildUsed++] = child; |
| 359 | } |
| 360 | db_finalize(&q); |
| 361 | for(i=1; i<nChildUsed; i++){ |
| 362 |
| --- src/content.c | |
| +++ src/content.c | |
| @@ -80,13 +80,12 @@ | |
| 80 | if( contentCache.n>500 || contentCache.szTotal>50000000 ){ |
| 81 | content_cache_expire_oldest(); |
| 82 | } |
| 83 | if( contentCache.n>=contentCache.nAlloc ){ |
| 84 | contentCache.nAlloc = contentCache.nAlloc*2 + 10; |
| 85 | contentCache.a = fossil_realloc(contentCache.a, |
| 86 | contentCache.nAlloc*sizeof(contentCache.a[0])); |
| 87 | } |
| 88 | p = &contentCache.a[contentCache.n++]; |
| 89 | p->rid = rid; |
| 90 | p->age = contentCache.nextAge++; |
| 91 | contentCache.szTotal += blob_size(pBlob); |
| @@ -240,22 +239,20 @@ | |
| 239 | int nAlloc = 10; |
| 240 | int *a = 0; |
| 241 | int mx; |
| 242 | Blob delta, next; |
| 243 | |
| 244 | a = fossil_malloc( sizeof(a[0])*nAlloc ); |
| 245 | a[0] = rid; |
| 246 | a[1] = nextRid; |
| 247 | n = 1; |
| 248 | while( !bag_find(&contentCache.inCache, nextRid) |
| 249 | && (nextRid = findSrcid(nextRid))>0 ){ |
| 250 | n++; |
| 251 | if( n>=nAlloc ){ |
| 252 | nAlloc = nAlloc*2 + 10; |
| 253 | a = fossil_realloc(a, nAlloc*sizeof(a[0])); |
| 254 | } |
| 255 | a[n] = nextRid; |
| 256 | } |
| 257 | mx = n; |
| 258 | rc = content_get(a[n], pBlob); |
| @@ -350,12 +347,11 @@ | |
| 347 | db_prepare(&q, "SELECT rid FROM delta WHERE srcid=%d", rid); |
| 348 | while( db_step(&q)==SQLITE_ROW ){ |
| 349 | int child = db_column_int(&q, 0); |
| 350 | if( nChildUsed>=nChildAlloc ){ |
| 351 | nChildAlloc = nChildAlloc*2 + 10; |
| 352 | aChild = fossil_realloc(aChild, nChildAlloc*sizeof(aChild)); |
| 353 | } |
| 354 | aChild[nChildUsed++] = child; |
| 355 | } |
| 356 | db_finalize(&q); |
| 357 | for(i=1; i<nChildUsed; i++){ |
| 358 |
+1
-2
| --- src/delta.c | ||
| +++ src/delta.c | ||
| @@ -317,12 +317,11 @@ | ||
| 317 | 317 | |
| 318 | 318 | /* Compute the hash table used to locate matching sections in the |
| 319 | 319 | ** source file. |
| 320 | 320 | */ |
| 321 | 321 | nHash = lenSrc/NHASH; |
| 322 | - collide = malloc( nHash*2*sizeof(int) ); | |
| 323 | - if( collide==0 ) return -1; | |
| 322 | + collide = fossil_malloc( nHash*2*sizeof(int) ); | |
| 324 | 323 | landmark = &collide[nHash]; |
| 325 | 324 | memset(landmark, -1, nHash*sizeof(int)); |
| 326 | 325 | memset(collide, -1, nHash*sizeof(int)); |
| 327 | 326 | for(i=0; i<lenSrc-NHASH; i+=NHASH){ |
| 328 | 327 | int hv; |
| 329 | 328 |
| --- src/delta.c | |
| +++ src/delta.c | |
| @@ -317,12 +317,11 @@ | |
| 317 | |
| 318 | /* Compute the hash table used to locate matching sections in the |
| 319 | ** source file. |
| 320 | */ |
| 321 | nHash = lenSrc/NHASH; |
| 322 | collide = malloc( nHash*2*sizeof(int) ); |
| 323 | if( collide==0 ) return -1; |
| 324 | landmark = &collide[nHash]; |
| 325 | memset(landmark, -1, nHash*sizeof(int)); |
| 326 | memset(collide, -1, nHash*sizeof(int)); |
| 327 | for(i=0; i<lenSrc-NHASH; i+=NHASH){ |
| 328 | int hv; |
| 329 |
| --- src/delta.c | |
| +++ src/delta.c | |
| @@ -317,12 +317,11 @@ | |
| 317 | |
| 318 | /* Compute the hash table used to locate matching sections in the |
| 319 | ** source file. |
| 320 | */ |
| 321 | nHash = lenSrc/NHASH; |
| 322 | collide = fossil_malloc( nHash*2*sizeof(int) ); |
| 323 | landmark = &collide[nHash]; |
| 324 | memset(landmark, -1, nHash*sizeof(int)); |
| 325 | memset(collide, -1, nHash*sizeof(int)); |
| 326 | for(i=0; i<lenSrc-NHASH; i+=NHASH){ |
| 327 | int hv; |
| 328 |
+3
-12
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -96,12 +96,11 @@ | ||
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | if( j>LENGTH_MASK ){ |
| 99 | 99 | return 0; |
| 100 | 100 | } |
| 101 | - a = malloc( nLine*sizeof(a[0]) ); | |
| 102 | - if( a==0 ) fossil_panic("out of memory"); | |
| 101 | + a = fossil_malloc( nLine*sizeof(a[0]) ); | |
| 103 | 102 | memset(a, 0, nLine*sizeof(a[0]) ); |
| 104 | 103 | if( n==0 ){ |
| 105 | 104 | *pnLine = 0; |
| 106 | 105 | return a; |
| 107 | 106 | } |
| @@ -145,18 +144,11 @@ | ||
| 145 | 144 | |
| 146 | 145 | /* |
| 147 | 146 | ** Expand the size of aEdit[] array to hold nEdit elements. |
| 148 | 147 | */ |
| 149 | 148 | static void expandEdit(DContext *p, int nEdit){ |
| 150 | - int *a; | |
| 151 | - a = realloc(p->aEdit, nEdit*sizeof(int)); | |
| 152 | - if( a==0 ){ | |
| 153 | - free( p->aEdit ); | |
| 154 | - p->nEdit = 0; | |
| 155 | - nEdit = 0; | |
| 156 | - } | |
| 157 | - p->aEdit = a; | |
| 149 | + p->aEdit = fossil_realloc(p->aEdit, nEdit*sizeof(int)); | |
| 158 | 150 | p->nEditAlloc = nEdit; |
| 159 | 151 | } |
| 160 | 152 | |
| 161 | 153 | /* |
| 162 | 154 | ** Append a new COPY/DELETE/INSERT triple. |
| @@ -649,12 +641,11 @@ | ||
| 649 | 641 | memset(p, 0, sizeof(*p)); |
| 650 | 642 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1); |
| 651 | 643 | if( p->c.aTo==0 ){ |
| 652 | 644 | return 1; |
| 653 | 645 | } |
| 654 | - p->aOrig = malloc( sizeof(p->aOrig[0])*p->c.nTo ); | |
| 655 | - if( p->aOrig==0 ) fossil_panic("out of memory"); | |
| 646 | + p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); | |
| 656 | 647 | for(i=0; i<p->c.nTo; i++){ |
| 657 | 648 | p->aOrig[i].z = p->c.aTo[i].z; |
| 658 | 649 | p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK; |
| 659 | 650 | p->aOrig[i].zSrc = 0; |
| 660 | 651 | } |
| 661 | 652 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -96,12 +96,11 @@ | |
| 96 | } |
| 97 | } |
| 98 | if( j>LENGTH_MASK ){ |
| 99 | return 0; |
| 100 | } |
| 101 | a = malloc( nLine*sizeof(a[0]) ); |
| 102 | if( a==0 ) fossil_panic("out of memory"); |
| 103 | memset(a, 0, nLine*sizeof(a[0]) ); |
| 104 | if( n==0 ){ |
| 105 | *pnLine = 0; |
| 106 | return a; |
| 107 | } |
| @@ -145,18 +144,11 @@ | |
| 145 | |
| 146 | /* |
| 147 | ** Expand the size of aEdit[] array to hold nEdit elements. |
| 148 | */ |
| 149 | static void expandEdit(DContext *p, int nEdit){ |
| 150 | int *a; |
| 151 | a = realloc(p->aEdit, nEdit*sizeof(int)); |
| 152 | if( a==0 ){ |
| 153 | free( p->aEdit ); |
| 154 | p->nEdit = 0; |
| 155 | nEdit = 0; |
| 156 | } |
| 157 | p->aEdit = a; |
| 158 | p->nEditAlloc = nEdit; |
| 159 | } |
| 160 | |
| 161 | /* |
| 162 | ** Append a new COPY/DELETE/INSERT triple. |
| @@ -649,12 +641,11 @@ | |
| 649 | memset(p, 0, sizeof(*p)); |
| 650 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1); |
| 651 | if( p->c.aTo==0 ){ |
| 652 | return 1; |
| 653 | } |
| 654 | p->aOrig = malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 655 | if( p->aOrig==0 ) fossil_panic("out of memory"); |
| 656 | for(i=0; i<p->c.nTo; i++){ |
| 657 | p->aOrig[i].z = p->c.aTo[i].z; |
| 658 | p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK; |
| 659 | p->aOrig[i].zSrc = 0; |
| 660 | } |
| 661 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -96,12 +96,11 @@ | |
| 96 | } |
| 97 | } |
| 98 | if( j>LENGTH_MASK ){ |
| 99 | return 0; |
| 100 | } |
| 101 | a = fossil_malloc( nLine*sizeof(a[0]) ); |
| 102 | memset(a, 0, nLine*sizeof(a[0]) ); |
| 103 | if( n==0 ){ |
| 104 | *pnLine = 0; |
| 105 | return a; |
| 106 | } |
| @@ -145,18 +144,11 @@ | |
| 144 | |
| 145 | /* |
| 146 | ** Expand the size of aEdit[] array to hold nEdit elements. |
| 147 | */ |
| 148 | static void expandEdit(DContext *p, int nEdit){ |
| 149 | p->aEdit = fossil_realloc(p->aEdit, nEdit*sizeof(int)); |
| 150 | p->nEditAlloc = nEdit; |
| 151 | } |
| 152 | |
| 153 | /* |
| 154 | ** Append a new COPY/DELETE/INSERT triple. |
| @@ -649,12 +641,11 @@ | |
| 641 | memset(p, 0, sizeof(*p)); |
| 642 | p->c.aTo = break_into_lines(blob_str(pInput), blob_size(pInput),&p->c.nTo,1); |
| 643 | if( p->c.aTo==0 ){ |
| 644 | return 1; |
| 645 | } |
| 646 | p->aOrig = fossil_malloc( sizeof(p->aOrig[0])*p->c.nTo ); |
| 647 | for(i=0; i<p->c.nTo; i++){ |
| 648 | p->aOrig[i].z = p->c.aTo[i].z; |
| 649 | p->aOrig[i].n = p->c.aTo[i].h & LENGTH_MASK; |
| 650 | p->aOrig[i].zSrc = 0; |
| 651 | } |
| 652 |
+7
-11
| --- src/encode.c | ||
| +++ src/encode.c | ||
| @@ -44,12 +44,11 @@ | ||
| 44 | 44 | default: count++; break; |
| 45 | 45 | } |
| 46 | 46 | i++; |
| 47 | 47 | } |
| 48 | 48 | i = 0; |
| 49 | - zOut = malloc( count+1 ); | |
| 50 | - if( zOut==0 ) return 0; | |
| 49 | + zOut = fossil_malloc( count+1 ); | |
| 51 | 50 | while( n-->0 && (c = *zIn)!=0 ){ |
| 52 | 51 | switch( c ){ |
| 53 | 52 | case '<': |
| 54 | 53 | zOut[i++] = '&'; |
| 55 | 54 | zOut[i++] = 'l'; |
| @@ -115,12 +114,11 @@ | ||
| 115 | 114 | count += 3; |
| 116 | 115 | } |
| 117 | 116 | i++; |
| 118 | 117 | } |
| 119 | 118 | i = 0; |
| 120 | - zOut = malloc( count+1 ); | |
| 121 | - if( zOut==0 ) return 0; | |
| 119 | + zOut = fossil_malloc( count+1 ); | |
| 122 | 120 | while( n-->0 && (c = *zIn)!=0 ){ |
| 123 | 121 | if( IsSafeChar(c) ){ |
| 124 | 122 | zOut[i++] = c; |
| 125 | 123 | }else if( c==' ' ){ |
| 126 | 124 | zOut[i++] = '+'; |
| @@ -234,11 +232,11 @@ | ||
| 234 | 232 | c = zIn[i]; |
| 235 | 233 | if( c==0 || c==' ' || c=='\n' || c=='\t' || c=='\r' || c=='\f' || c=='\v' |
| 236 | 234 | || c=='\\' ) n++; |
| 237 | 235 | } |
| 238 | 236 | n += nIn; |
| 239 | - zOut = malloc( n+1 ); | |
| 237 | + zOut = fossil_malloc( n+1 ); | |
| 240 | 238 | if( zOut ){ |
| 241 | 239 | for(i=j=0; i<nIn; i++){ |
| 242 | 240 | int c = zIn[i]; |
| 243 | 241 | if( c==0 ){ |
| 244 | 242 | zOut[j++] = '\\'; |
| @@ -310,11 +308,11 @@ | ||
| 310 | 308 | int i, n; |
| 311 | 309 | |
| 312 | 310 | if( nData<=0 ){ |
| 313 | 311 | nData = strlen(zData); |
| 314 | 312 | } |
| 315 | - z64 = malloc( (nData*4)/3 + 8 ); | |
| 313 | + z64 = fossil_malloc( (nData*4)/3 + 8 ); | |
| 316 | 314 | for(i=n=0; i+2<nData; i+=3){ |
| 317 | 315 | z64[n++] = zBase[ (zData[i]>>2) & 0x3f ]; |
| 318 | 316 | z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ]; |
| 319 | 317 | z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ]; |
| 320 | 318 | z64[n++] = zBase[ zData[i+2] & 0x3f ]; |
| @@ -371,11 +369,11 @@ | ||
| 371 | 369 | for(i=0; zBase[i]; i++){ trans[zBase[i] & 0x7f] = i; } |
| 372 | 370 | isInit = 1; |
| 373 | 371 | } |
| 374 | 372 | n64 = strlen(z64); |
| 375 | 373 | while( n64>0 && z64[n64-1]=='=' ) n64--; |
| 376 | - zData = malloc( (n64*3)/4 + 4 ); | |
| 374 | + zData = fossil_malloc( (n64*3)/4 + 4 ); | |
| 377 | 375 | for(i=j=0; i+3<n64; i+=4){ |
| 378 | 376 | a = trans[z64[i] & 0x7f]; |
| 379 | 377 | b = trans[z64[i+1] & 0x7f]; |
| 380 | 378 | c = trans[z64[i+2] & 0x7f]; |
| 381 | 379 | d = trans[z64[i+3] & 0x7f]; |
| @@ -532,12 +530,11 @@ | ||
| 532 | 530 | unsigned char salt; |
| 533 | 531 | char *zOut; |
| 534 | 532 | |
| 535 | 533 | if( zIn==0 ) return 0; |
| 536 | 534 | n = strlen(zIn); |
| 537 | - zOut = malloc( n*2+3 ); | |
| 538 | - if( zOut==0 ) fossil_panic("out of memory"); | |
| 535 | + zOut = fossil_malloc( n*2+3 ); | |
| 539 | 536 | sqlite3_randomness(1, &salt); |
| 540 | 537 | zOut[n+1] = (char)salt; |
| 541 | 538 | for(i=0; i<n; i++) zOut[i+n+2] = zIn[i]^aObscurer[i&0x0f]^salt; |
| 542 | 539 | encode16((unsigned char*)&zOut[n+1], (unsigned char*)zOut, n+1); |
| 543 | 540 | return zOut; |
| @@ -555,12 +552,11 @@ | ||
| 555 | 552 | unsigned char salt; |
| 556 | 553 | char *zOut; |
| 557 | 554 | |
| 558 | 555 | if( zIn==0 ) return 0; |
| 559 | 556 | n = strlen(zIn); |
| 560 | - zOut = malloc( n + 1 ); | |
| 561 | - if( zOut==0 ) fossil_panic("out of memory"); | |
| 557 | + zOut = fossil_malloc( n + 1 ); | |
| 562 | 558 | if( n<2 |
| 563 | 559 | || decode16((unsigned char*)zIn, &salt, 2) |
| 564 | 560 | || decode16((unsigned char*)&zIn[2], (unsigned char*)zOut, n-2) |
| 565 | 561 | ){ |
| 566 | 562 | memcpy(zOut, zIn, n+1); |
| 567 | 563 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -44,12 +44,11 @@ | |
| 44 | default: count++; break; |
| 45 | } |
| 46 | i++; |
| 47 | } |
| 48 | i = 0; |
| 49 | zOut = malloc( count+1 ); |
| 50 | if( zOut==0 ) return 0; |
| 51 | while( n-->0 && (c = *zIn)!=0 ){ |
| 52 | switch( c ){ |
| 53 | case '<': |
| 54 | zOut[i++] = '&'; |
| 55 | zOut[i++] = 'l'; |
| @@ -115,12 +114,11 @@ | |
| 115 | count += 3; |
| 116 | } |
| 117 | i++; |
| 118 | } |
| 119 | i = 0; |
| 120 | zOut = malloc( count+1 ); |
| 121 | if( zOut==0 ) return 0; |
| 122 | while( n-->0 && (c = *zIn)!=0 ){ |
| 123 | if( IsSafeChar(c) ){ |
| 124 | zOut[i++] = c; |
| 125 | }else if( c==' ' ){ |
| 126 | zOut[i++] = '+'; |
| @@ -234,11 +232,11 @@ | |
| 234 | c = zIn[i]; |
| 235 | if( c==0 || c==' ' || c=='\n' || c=='\t' || c=='\r' || c=='\f' || c=='\v' |
| 236 | || c=='\\' ) n++; |
| 237 | } |
| 238 | n += nIn; |
| 239 | zOut = malloc( n+1 ); |
| 240 | if( zOut ){ |
| 241 | for(i=j=0; i<nIn; i++){ |
| 242 | int c = zIn[i]; |
| 243 | if( c==0 ){ |
| 244 | zOut[j++] = '\\'; |
| @@ -310,11 +308,11 @@ | |
| 310 | int i, n; |
| 311 | |
| 312 | if( nData<=0 ){ |
| 313 | nData = strlen(zData); |
| 314 | } |
| 315 | z64 = malloc( (nData*4)/3 + 8 ); |
| 316 | for(i=n=0; i+2<nData; i+=3){ |
| 317 | z64[n++] = zBase[ (zData[i]>>2) & 0x3f ]; |
| 318 | z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ]; |
| 319 | z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ]; |
| 320 | z64[n++] = zBase[ zData[i+2] & 0x3f ]; |
| @@ -371,11 +369,11 @@ | |
| 371 | for(i=0; zBase[i]; i++){ trans[zBase[i] & 0x7f] = i; } |
| 372 | isInit = 1; |
| 373 | } |
| 374 | n64 = strlen(z64); |
| 375 | while( n64>0 && z64[n64-1]=='=' ) n64--; |
| 376 | zData = malloc( (n64*3)/4 + 4 ); |
| 377 | for(i=j=0; i+3<n64; i+=4){ |
| 378 | a = trans[z64[i] & 0x7f]; |
| 379 | b = trans[z64[i+1] & 0x7f]; |
| 380 | c = trans[z64[i+2] & 0x7f]; |
| 381 | d = trans[z64[i+3] & 0x7f]; |
| @@ -532,12 +530,11 @@ | |
| 532 | unsigned char salt; |
| 533 | char *zOut; |
| 534 | |
| 535 | if( zIn==0 ) return 0; |
| 536 | n = strlen(zIn); |
| 537 | zOut = malloc( n*2+3 ); |
| 538 | if( zOut==0 ) fossil_panic("out of memory"); |
| 539 | sqlite3_randomness(1, &salt); |
| 540 | zOut[n+1] = (char)salt; |
| 541 | for(i=0; i<n; i++) zOut[i+n+2] = zIn[i]^aObscurer[i&0x0f]^salt; |
| 542 | encode16((unsigned char*)&zOut[n+1], (unsigned char*)zOut, n+1); |
| 543 | return zOut; |
| @@ -555,12 +552,11 @@ | |
| 555 | unsigned char salt; |
| 556 | char *zOut; |
| 557 | |
| 558 | if( zIn==0 ) return 0; |
| 559 | n = strlen(zIn); |
| 560 | zOut = malloc( n + 1 ); |
| 561 | if( zOut==0 ) fossil_panic("out of memory"); |
| 562 | if( n<2 |
| 563 | || decode16((unsigned char*)zIn, &salt, 2) |
| 564 | || decode16((unsigned char*)&zIn[2], (unsigned char*)zOut, n-2) |
| 565 | ){ |
| 566 | memcpy(zOut, zIn, n+1); |
| 567 |
| --- src/encode.c | |
| +++ src/encode.c | |
| @@ -44,12 +44,11 @@ | |
| 44 | default: count++; break; |
| 45 | } |
| 46 | i++; |
| 47 | } |
| 48 | i = 0; |
| 49 | zOut = fossil_malloc( count+1 ); |
| 50 | while( n-->0 && (c = *zIn)!=0 ){ |
| 51 | switch( c ){ |
| 52 | case '<': |
| 53 | zOut[i++] = '&'; |
| 54 | zOut[i++] = 'l'; |
| @@ -115,12 +114,11 @@ | |
| 114 | count += 3; |
| 115 | } |
| 116 | i++; |
| 117 | } |
| 118 | i = 0; |
| 119 | zOut = fossil_malloc( count+1 ); |
| 120 | while( n-->0 && (c = *zIn)!=0 ){ |
| 121 | if( IsSafeChar(c) ){ |
| 122 | zOut[i++] = c; |
| 123 | }else if( c==' ' ){ |
| 124 | zOut[i++] = '+'; |
| @@ -234,11 +232,11 @@ | |
| 232 | c = zIn[i]; |
| 233 | if( c==0 || c==' ' || c=='\n' || c=='\t' || c=='\r' || c=='\f' || c=='\v' |
| 234 | || c=='\\' ) n++; |
| 235 | } |
| 236 | n += nIn; |
| 237 | zOut = fossil_malloc( n+1 ); |
| 238 | if( zOut ){ |
| 239 | for(i=j=0; i<nIn; i++){ |
| 240 | int c = zIn[i]; |
| 241 | if( c==0 ){ |
| 242 | zOut[j++] = '\\'; |
| @@ -310,11 +308,11 @@ | |
| 308 | int i, n; |
| 309 | |
| 310 | if( nData<=0 ){ |
| 311 | nData = strlen(zData); |
| 312 | } |
| 313 | z64 = fossil_malloc( (nData*4)/3 + 8 ); |
| 314 | for(i=n=0; i+2<nData; i+=3){ |
| 315 | z64[n++] = zBase[ (zData[i]>>2) & 0x3f ]; |
| 316 | z64[n++] = zBase[ ((zData[i]<<4) & 0x30) | ((zData[i+1]>>4) & 0x0f) ]; |
| 317 | z64[n++] = zBase[ ((zData[i+1]<<2) & 0x3c) | ((zData[i+2]>>6) & 0x03) ]; |
| 318 | z64[n++] = zBase[ zData[i+2] & 0x3f ]; |
| @@ -371,11 +369,11 @@ | |
| 369 | for(i=0; zBase[i]; i++){ trans[zBase[i] & 0x7f] = i; } |
| 370 | isInit = 1; |
| 371 | } |
| 372 | n64 = strlen(z64); |
| 373 | while( n64>0 && z64[n64-1]=='=' ) n64--; |
| 374 | zData = fossil_malloc( (n64*3)/4 + 4 ); |
| 375 | for(i=j=0; i+3<n64; i+=4){ |
| 376 | a = trans[z64[i] & 0x7f]; |
| 377 | b = trans[z64[i+1] & 0x7f]; |
| 378 | c = trans[z64[i+2] & 0x7f]; |
| 379 | d = trans[z64[i+3] & 0x7f]; |
| @@ -532,12 +530,11 @@ | |
| 530 | unsigned char salt; |
| 531 | char *zOut; |
| 532 | |
| 533 | if( zIn==0 ) return 0; |
| 534 | n = strlen(zIn); |
| 535 | zOut = fossil_malloc( n*2+3 ); |
| 536 | sqlite3_randomness(1, &salt); |
| 537 | zOut[n+1] = (char)salt; |
| 538 | for(i=0; i<n; i++) zOut[i+n+2] = zIn[i]^aObscurer[i&0x0f]^salt; |
| 539 | encode16((unsigned char*)&zOut[n+1], (unsigned char*)zOut, n+1); |
| 540 | return zOut; |
| @@ -555,12 +552,11 @@ | |
| 552 | unsigned char salt; |
| 553 | char *zOut; |
| 554 | |
| 555 | if( zIn==0 ) return 0; |
| 556 | n = strlen(zIn); |
| 557 | zOut = fossil_malloc( n + 1 ); |
| 558 | if( n<2 |
| 559 | || decode16((unsigned char*)zIn, &salt, 2) |
| 560 | || decode16((unsigned char*)&zIn[2], (unsigned char*)zOut, n-2) |
| 561 | ){ |
| 562 | memcpy(zOut, zIn, n+1); |
| 563 |
+2
-4
| --- src/graph.c | ||
| +++ src/graph.c | ||
| @@ -72,12 +72,11 @@ | ||
| 72 | 72 | /* |
| 73 | 73 | ** Malloc for zeroed space. Panic if unable to provide the |
| 74 | 74 | ** requested space. |
| 75 | 75 | */ |
| 76 | 76 | void *safeMalloc(int nByte){ |
| 77 | - void *p = malloc(nByte); | |
| 78 | - if( p==0 ) fossil_panic("out of memory"); | |
| 77 | + void *p = fossil_malloc(nByte); | |
| 79 | 78 | memset(p, 0, nByte); |
| 80 | 79 | return p; |
| 81 | 80 | } |
| 82 | 81 | |
| 83 | 82 | /* |
| @@ -148,12 +147,11 @@ | ||
| 148 | 147 | int i; |
| 149 | 148 | for(i=0; i<p->nBranch; i++){ |
| 150 | 149 | if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i]; |
| 151 | 150 | } |
| 152 | 151 | p->nBranch++; |
| 153 | - p->azBranch = realloc(p->azBranch, sizeof(char*)*p->nBranch); | |
| 154 | - if( p->azBranch==0 ) fossil_panic("out of memory"); | |
| 152 | + p->azBranch = fossil_realloc(p->azBranch, sizeof(char*)*p->nBranch); | |
| 155 | 153 | p->azBranch[p->nBranch-1] = mprintf("%s", zBranch); |
| 156 | 154 | return p->azBranch[p->nBranch-1]; |
| 157 | 155 | } |
| 158 | 156 | |
| 159 | 157 | /* |
| 160 | 158 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -72,12 +72,11 @@ | |
| 72 | /* |
| 73 | ** Malloc for zeroed space. Panic if unable to provide the |
| 74 | ** requested space. |
| 75 | */ |
| 76 | void *safeMalloc(int nByte){ |
| 77 | void *p = malloc(nByte); |
| 78 | if( p==0 ) fossil_panic("out of memory"); |
| 79 | memset(p, 0, nByte); |
| 80 | return p; |
| 81 | } |
| 82 | |
| 83 | /* |
| @@ -148,12 +147,11 @@ | |
| 148 | int i; |
| 149 | for(i=0; i<p->nBranch; i++){ |
| 150 | if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i]; |
| 151 | } |
| 152 | p->nBranch++; |
| 153 | p->azBranch = realloc(p->azBranch, sizeof(char*)*p->nBranch); |
| 154 | if( p->azBranch==0 ) fossil_panic("out of memory"); |
| 155 | p->azBranch[p->nBranch-1] = mprintf("%s", zBranch); |
| 156 | return p->azBranch[p->nBranch-1]; |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 |
| --- src/graph.c | |
| +++ src/graph.c | |
| @@ -72,12 +72,11 @@ | |
| 72 | /* |
| 73 | ** Malloc for zeroed space. Panic if unable to provide the |
| 74 | ** requested space. |
| 75 | */ |
| 76 | void *safeMalloc(int nByte){ |
| 77 | void *p = fossil_malloc(nByte); |
| 78 | memset(p, 0, nByte); |
| 79 | return p; |
| 80 | } |
| 81 | |
| 82 | /* |
| @@ -148,12 +147,11 @@ | |
| 147 | int i; |
| 148 | for(i=0; i<p->nBranch; i++){ |
| 149 | if( strcmp(zBranch, p->azBranch[i])==0 ) return p->azBranch[i]; |
| 150 | } |
| 151 | p->nBranch++; |
| 152 | p->azBranch = fossil_realloc(p->azBranch, sizeof(char*)*p->nBranch); |
| 153 | p->azBranch[p->nBranch-1] = mprintf("%s", zBranch); |
| 154 | return p->azBranch[p->nBranch-1]; |
| 155 | } |
| 156 | |
| 157 | /* |
| 158 |
+2
-4
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -386,12 +386,11 @@ | ||
| 386 | 386 | */ |
| 387 | 387 | static void transport_load_buffer(int N){ |
| 388 | 388 | int i, j; |
| 389 | 389 | if( transport.nAlloc==0 ){ |
| 390 | 390 | transport.nAlloc = N; |
| 391 | - transport.pBuf = malloc( N ); | |
| 392 | - if( transport.pBuf==0 ) fossil_panic("out of memory"); | |
| 391 | + transport.pBuf = fossil_malloc( N ); | |
| 393 | 392 | transport.iCursor = 0; |
| 394 | 393 | transport.nUsed = 0; |
| 395 | 394 | } |
| 396 | 395 | if( transport.iCursor>0 ){ |
| 397 | 396 | for(i=0, j=transport.iCursor; j<transport.nUsed; i++, j++){ |
| @@ -401,12 +400,11 @@ | ||
| 401 | 400 | transport.iCursor = 0; |
| 402 | 401 | } |
| 403 | 402 | if( transport.nUsed + N > transport.nAlloc ){ |
| 404 | 403 | char *pNew; |
| 405 | 404 | transport.nAlloc = transport.nUsed + N; |
| 406 | - pNew = realloc(transport.pBuf, transport.nAlloc); | |
| 407 | - if( pNew==0 ) fossil_panic("out of memory"); | |
| 405 | + pNew = fossil_realloc(transport.pBuf, transport.nAlloc); | |
| 408 | 406 | transport.pBuf = pNew; |
| 409 | 407 | } |
| 410 | 408 | if( N>0 ){ |
| 411 | 409 | i = transport_fetch(&transport.pBuf[transport.nUsed], N); |
| 412 | 410 | if( i>0 ){ |
| 413 | 411 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -386,12 +386,11 @@ | |
| 386 | */ |
| 387 | static void transport_load_buffer(int N){ |
| 388 | int i, j; |
| 389 | if( transport.nAlloc==0 ){ |
| 390 | transport.nAlloc = N; |
| 391 | transport.pBuf = malloc( N ); |
| 392 | if( transport.pBuf==0 ) fossil_panic("out of memory"); |
| 393 | transport.iCursor = 0; |
| 394 | transport.nUsed = 0; |
| 395 | } |
| 396 | if( transport.iCursor>0 ){ |
| 397 | for(i=0, j=transport.iCursor; j<transport.nUsed; i++, j++){ |
| @@ -401,12 +400,11 @@ | |
| 401 | transport.iCursor = 0; |
| 402 | } |
| 403 | if( transport.nUsed + N > transport.nAlloc ){ |
| 404 | char *pNew; |
| 405 | transport.nAlloc = transport.nUsed + N; |
| 406 | pNew = realloc(transport.pBuf, transport.nAlloc); |
| 407 | if( pNew==0 ) fossil_panic("out of memory"); |
| 408 | transport.pBuf = pNew; |
| 409 | } |
| 410 | if( N>0 ){ |
| 411 | i = transport_fetch(&transport.pBuf[transport.nUsed], N); |
| 412 | if( i>0 ){ |
| 413 |
| --- src/http_transport.c | |
| +++ src/http_transport.c | |
| @@ -386,12 +386,11 @@ | |
| 386 | */ |
| 387 | static void transport_load_buffer(int N){ |
| 388 | int i, j; |
| 389 | if( transport.nAlloc==0 ){ |
| 390 | transport.nAlloc = N; |
| 391 | transport.pBuf = fossil_malloc( N ); |
| 392 | transport.iCursor = 0; |
| 393 | transport.nUsed = 0; |
| 394 | } |
| 395 | if( transport.iCursor>0 ){ |
| 396 | for(i=0, j=transport.iCursor; j<transport.nUsed; i++, j++){ |
| @@ -401,12 +400,11 @@ | |
| 400 | transport.iCursor = 0; |
| 401 | } |
| 402 | if( transport.nUsed + N > transport.nAlloc ){ |
| 403 | char *pNew; |
| 404 | transport.nAlloc = transport.nUsed + N; |
| 405 | pNew = fossil_realloc(transport.pBuf, transport.nAlloc); |
| 406 | transport.pBuf = pNew; |
| 407 | } |
| 408 | if( N>0 ){ |
| 409 | i = transport_fetch(&transport.pBuf[transport.nUsed], N); |
| 410 | if( i>0 ){ |
| 411 |
+1
-1
| --- src/login.c | ||
| +++ src/login.c | ||
| @@ -52,11 +52,11 @@ | ||
| 52 | 52 | */ |
| 53 | 53 | static char *login_cookie_name(void){ |
| 54 | 54 | static char *zCookieName = 0; |
| 55 | 55 | if( zCookieName==0 ){ |
| 56 | 56 | int n = strlen(g.zTop); |
| 57 | - zCookieName = malloc( n*2+16 ); | |
| 57 | + zCookieName = fossil_malloc( n*2+16 ); | |
| 58 | 58 | /* 0123456789 12345 */ |
| 59 | 59 | strcpy(zCookieName, "fossil_login_"); |
| 60 | 60 | encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n); |
| 61 | 61 | } |
| 62 | 62 | return zCookieName; |
| 63 | 63 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -52,11 +52,11 @@ | |
| 52 | */ |
| 53 | static char *login_cookie_name(void){ |
| 54 | static char *zCookieName = 0; |
| 55 | if( zCookieName==0 ){ |
| 56 | int n = strlen(g.zTop); |
| 57 | zCookieName = malloc( n*2+16 ); |
| 58 | /* 0123456789 12345 */ |
| 59 | strcpy(zCookieName, "fossil_login_"); |
| 60 | encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n); |
| 61 | } |
| 62 | return zCookieName; |
| 63 |
| --- src/login.c | |
| +++ src/login.c | |
| @@ -52,11 +52,11 @@ | |
| 52 | */ |
| 53 | static char *login_cookie_name(void){ |
| 54 | static char *zCookieName = 0; |
| 55 | if( zCookieName==0 ){ |
| 56 | int n = strlen(g.zTop); |
| 57 | zCookieName = fossil_malloc( n*2+16 ); |
| 58 | /* 0123456789 12345 */ |
| 59 | strcpy(zCookieName, "fossil_login_"); |
| 60 | encode16((unsigned char*)g.zTop, (unsigned char*)&zCookieName[13], n); |
| 61 | } |
| 62 | return zCookieName; |
| 63 |
+18
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -359,10 +359,28 @@ | ||
| 359 | 359 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 360 | 360 | }else{ |
| 361 | 361 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 362 | 362 | } |
| 363 | 363 | } |
| 364 | + | |
| 365 | +/* | |
| 366 | +** Malloc and free routines that cannot fail | |
| 367 | +*/ | |
| 368 | +void *fossil_malloc(size_t n){ | |
| 369 | + void *p = malloc(n); | |
| 370 | + if( p==0 ) fossil_panic("out of memory"); | |
| 371 | + return p; | |
| 372 | +} | |
| 373 | +void fossil_free(void *p){ | |
| 374 | + free(p); | |
| 375 | +} | |
| 376 | +void *fossil_realloc(void *p, size_t n){ | |
| 377 | + p = realloc(p, n); | |
| 378 | + if( p==0 ) fossil_panic("out of memory"); | |
| 379 | + return p; | |
| 380 | +} | |
| 381 | + | |
| 364 | 382 | |
| 365 | 383 | /* |
| 366 | 384 | ** Return a name for an SQLite error code |
| 367 | 385 | */ |
| 368 | 386 | static const char *sqlite_error_code_name(int iCode){ |
| 369 | 387 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -359,10 +359,28 @@ | |
| 359 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 360 | }else{ |
| 361 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | ** Return a name for an SQLite error code |
| 367 | */ |
| 368 | static const char *sqlite_error_code_name(int iCode){ |
| 369 |
| --- src/main.c | |
| +++ src/main.c | |
| @@ -359,10 +359,28 @@ | |
| 359 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 360 | }else{ |
| 361 | fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | /* |
| 366 | ** Malloc and free routines that cannot fail |
| 367 | */ |
| 368 | void *fossil_malloc(size_t n){ |
| 369 | void *p = malloc(n); |
| 370 | if( p==0 ) fossil_panic("out of memory"); |
| 371 | return p; |
| 372 | } |
| 373 | void fossil_free(void *p){ |
| 374 | free(p); |
| 375 | } |
| 376 | void *fossil_realloc(void *p, size_t n){ |
| 377 | p = realloc(p, n); |
| 378 | if( p==0 ) fossil_panic("out of memory"); |
| 379 | return p; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | /* |
| 384 | ** Return a name for an SQLite error code |
| 385 | */ |
| 386 | static const char *sqlite_error_code_name(int iCode){ |
| 387 |
+8
-11
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -364,12 +364,12 @@ | ||
| 364 | 364 | }else{ |
| 365 | 365 | zPriorName = 0; |
| 366 | 366 | } |
| 367 | 367 | if( p->nFile>=p->nFileAlloc ){ |
| 368 | 368 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 369 | - p->aFile = realloc(p->aFile, p->nFileAlloc*sizeof(p->aFile[0]) ); | |
| 370 | - if( p->aFile==0 ) fossil_panic("out of memory"); | |
| 369 | + p->aFile = fossil_realloc(p->aFile, | |
| 370 | + p->nFileAlloc*sizeof(p->aFile[0]) ); | |
| 371 | 371 | } |
| 372 | 372 | i = p->nFile++; |
| 373 | 373 | p->aFile[i].zName = zName; |
| 374 | 374 | p->aFile[i].zUuid = zUuid; |
| 375 | 375 | p->aFile[i].zPerm = zPerm; |
| @@ -398,13 +398,12 @@ | ||
| 398 | 398 | zName = blob_terminate(&a1); |
| 399 | 399 | zValue = blob_terminate(&a2); |
| 400 | 400 | defossilize(zValue); |
| 401 | 401 | if( p->nField>=p->nFieldAlloc ){ |
| 402 | 402 | p->nFieldAlloc = p->nFieldAlloc*2 + 10; |
| 403 | - p->aField = realloc(p->aField, | |
| 403 | + p->aField = fossil_realloc(p->aField, | |
| 404 | 404 | p->nFieldAlloc*sizeof(p->aField[0]) ); |
| 405 | - if( p->aField==0 ) fossil_panic("out of memory"); | |
| 406 | 405 | } |
| 407 | 406 | i = p->nField++; |
| 408 | 407 | p->aField[i].zName = zName; |
| 409 | 408 | p->aField[i].zValue = zValue; |
| 410 | 409 | if( i>0 && strcmp(p->aField[i-1].zName, zName)>=0 ){ |
| @@ -464,13 +463,12 @@ | ||
| 464 | 463 | zUuid = blob_terminate(&a1); |
| 465 | 464 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 466 | 465 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 467 | 466 | if( p->nCChild>=p->nCChildAlloc ){ |
| 468 | 467 | p->nCChildAlloc = p->nCChildAlloc*2 + 10; |
| 469 | - p->azCChild = | |
| 470 | - realloc(p->azCChild, p->nCChildAlloc*sizeof(p->azCChild[0]) ); | |
| 471 | - if( p->azCChild==0 ) fossil_panic("out of memory"); | |
| 468 | + p->azCChild = fossil_realloc(p->azCChild | |
| 469 | + , p->nCChildAlloc*sizeof(p->azCChild[0]) ); | |
| 472 | 470 | } |
| 473 | 471 | i = p->nCChild++; |
| 474 | 472 | p->azCChild[i] = zUuid; |
| 475 | 473 | if( i>0 && strcmp(p->azCChild[i-1], zUuid)>=0 ){ |
| 476 | 474 | goto manifest_syntax_error; |
| @@ -492,12 +490,12 @@ | ||
| 492 | 490 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 493 | 491 | zUuid = blob_terminate(&a1); |
| 494 | 492 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 495 | 493 | if( p->nParent>=p->nParentAlloc ){ |
| 496 | 494 | p->nParentAlloc = p->nParentAlloc*2 + 5; |
| 497 | - p->azParent = realloc(p->azParent, p->nParentAlloc*sizeof(char*)); | |
| 498 | - if( p->azParent==0 ) fossil_panic("out of memory"); | |
| 495 | + p->azParent = fossil_realloc(p->azParent, | |
| 496 | + p->nParentAlloc*sizeof(char*)); | |
| 499 | 497 | } |
| 500 | 498 | i = p->nParent++; |
| 501 | 499 | p->azParent[i] = zUuid; |
| 502 | 500 | } |
| 503 | 501 | break; |
| @@ -567,12 +565,11 @@ | ||
| 567 | 565 | /* Do not allow tags whose names look like UUIDs */ |
| 568 | 566 | goto manifest_syntax_error; |
| 569 | 567 | } |
| 570 | 568 | if( p->nTag>=p->nTagAlloc ){ |
| 571 | 569 | p->nTagAlloc = p->nTagAlloc*2 + 10; |
| 572 | - p->aTag = realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) ); | |
| 573 | - if( p->aTag==0 ) fossil_panic("out of memory"); | |
| 570 | + p->aTag = fossil_realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) ); | |
| 574 | 571 | } |
| 575 | 572 | i = p->nTag++; |
| 576 | 573 | p->aTag[i].zName = zName; |
| 577 | 574 | p->aTag[i].zUuid = zUuid; |
| 578 | 575 | p->aTag[i].zValue = zValue; |
| 579 | 576 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -364,12 +364,12 @@ | |
| 364 | }else{ |
| 365 | zPriorName = 0; |
| 366 | } |
| 367 | if( p->nFile>=p->nFileAlloc ){ |
| 368 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 369 | p->aFile = realloc(p->aFile, p->nFileAlloc*sizeof(p->aFile[0]) ); |
| 370 | if( p->aFile==0 ) fossil_panic("out of memory"); |
| 371 | } |
| 372 | i = p->nFile++; |
| 373 | p->aFile[i].zName = zName; |
| 374 | p->aFile[i].zUuid = zUuid; |
| 375 | p->aFile[i].zPerm = zPerm; |
| @@ -398,13 +398,12 @@ | |
| 398 | zName = blob_terminate(&a1); |
| 399 | zValue = blob_terminate(&a2); |
| 400 | defossilize(zValue); |
| 401 | if( p->nField>=p->nFieldAlloc ){ |
| 402 | p->nFieldAlloc = p->nFieldAlloc*2 + 10; |
| 403 | p->aField = realloc(p->aField, |
| 404 | p->nFieldAlloc*sizeof(p->aField[0]) ); |
| 405 | if( p->aField==0 ) fossil_panic("out of memory"); |
| 406 | } |
| 407 | i = p->nField++; |
| 408 | p->aField[i].zName = zName; |
| 409 | p->aField[i].zValue = zValue; |
| 410 | if( i>0 && strcmp(p->aField[i-1].zName, zName)>=0 ){ |
| @@ -464,13 +463,12 @@ | |
| 464 | zUuid = blob_terminate(&a1); |
| 465 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 466 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 467 | if( p->nCChild>=p->nCChildAlloc ){ |
| 468 | p->nCChildAlloc = p->nCChildAlloc*2 + 10; |
| 469 | p->azCChild = |
| 470 | realloc(p->azCChild, p->nCChildAlloc*sizeof(p->azCChild[0]) ); |
| 471 | if( p->azCChild==0 ) fossil_panic("out of memory"); |
| 472 | } |
| 473 | i = p->nCChild++; |
| 474 | p->azCChild[i] = zUuid; |
| 475 | if( i>0 && strcmp(p->azCChild[i-1], zUuid)>=0 ){ |
| 476 | goto manifest_syntax_error; |
| @@ -492,12 +490,12 @@ | |
| 492 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 493 | zUuid = blob_terminate(&a1); |
| 494 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 495 | if( p->nParent>=p->nParentAlloc ){ |
| 496 | p->nParentAlloc = p->nParentAlloc*2 + 5; |
| 497 | p->azParent = realloc(p->azParent, p->nParentAlloc*sizeof(char*)); |
| 498 | if( p->azParent==0 ) fossil_panic("out of memory"); |
| 499 | } |
| 500 | i = p->nParent++; |
| 501 | p->azParent[i] = zUuid; |
| 502 | } |
| 503 | break; |
| @@ -567,12 +565,11 @@ | |
| 567 | /* Do not allow tags whose names look like UUIDs */ |
| 568 | goto manifest_syntax_error; |
| 569 | } |
| 570 | if( p->nTag>=p->nTagAlloc ){ |
| 571 | p->nTagAlloc = p->nTagAlloc*2 + 10; |
| 572 | p->aTag = realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) ); |
| 573 | if( p->aTag==0 ) fossil_panic("out of memory"); |
| 574 | } |
| 575 | i = p->nTag++; |
| 576 | p->aTag[i].zName = zName; |
| 577 | p->aTag[i].zUuid = zUuid; |
| 578 | p->aTag[i].zValue = zValue; |
| 579 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -364,12 +364,12 @@ | |
| 364 | }else{ |
| 365 | zPriorName = 0; |
| 366 | } |
| 367 | if( p->nFile>=p->nFileAlloc ){ |
| 368 | p->nFileAlloc = p->nFileAlloc*2 + 10; |
| 369 | p->aFile = fossil_realloc(p->aFile, |
| 370 | p->nFileAlloc*sizeof(p->aFile[0]) ); |
| 371 | } |
| 372 | i = p->nFile++; |
| 373 | p->aFile[i].zName = zName; |
| 374 | p->aFile[i].zUuid = zUuid; |
| 375 | p->aFile[i].zPerm = zPerm; |
| @@ -398,13 +398,12 @@ | |
| 398 | zName = blob_terminate(&a1); |
| 399 | zValue = blob_terminate(&a2); |
| 400 | defossilize(zValue); |
| 401 | if( p->nField>=p->nFieldAlloc ){ |
| 402 | p->nFieldAlloc = p->nFieldAlloc*2 + 10; |
| 403 | p->aField = fossil_realloc(p->aField, |
| 404 | p->nFieldAlloc*sizeof(p->aField[0]) ); |
| 405 | } |
| 406 | i = p->nField++; |
| 407 | p->aField[i].zName = zName; |
| 408 | p->aField[i].zValue = zValue; |
| 409 | if( i>0 && strcmp(p->aField[i-1].zName, zName)>=0 ){ |
| @@ -464,13 +463,12 @@ | |
| 463 | zUuid = blob_terminate(&a1); |
| 464 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 465 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 466 | if( p->nCChild>=p->nCChildAlloc ){ |
| 467 | p->nCChildAlloc = p->nCChildAlloc*2 + 10; |
| 468 | p->azCChild = fossil_realloc(p->azCChild |
| 469 | , p->nCChildAlloc*sizeof(p->azCChild[0]) ); |
| 470 | } |
| 471 | i = p->nCChild++; |
| 472 | p->azCChild[i] = zUuid; |
| 473 | if( i>0 && strcmp(p->azCChild[i-1], zUuid)>=0 ){ |
| 474 | goto manifest_syntax_error; |
| @@ -492,12 +490,12 @@ | |
| 490 | if( blob_size(&a1)!=UUID_SIZE ) goto manifest_syntax_error; |
| 491 | zUuid = blob_terminate(&a1); |
| 492 | if( !validate16(zUuid, UUID_SIZE) ) goto manifest_syntax_error; |
| 493 | if( p->nParent>=p->nParentAlloc ){ |
| 494 | p->nParentAlloc = p->nParentAlloc*2 + 5; |
| 495 | p->azParent = fossil_realloc(p->azParent, |
| 496 | p->nParentAlloc*sizeof(char*)); |
| 497 | } |
| 498 | i = p->nParent++; |
| 499 | p->azParent[i] = zUuid; |
| 500 | } |
| 501 | break; |
| @@ -567,12 +565,11 @@ | |
| 565 | /* Do not allow tags whose names look like UUIDs */ |
| 566 | goto manifest_syntax_error; |
| 567 | } |
| 568 | if( p->nTag>=p->nTagAlloc ){ |
| 569 | p->nTagAlloc = p->nTagAlloc*2 + 10; |
| 570 | p->aTag = fossil_realloc(p->aTag, p->nTagAlloc*sizeof(p->aTag[0]) ); |
| 571 | } |
| 572 | i = p->nTag++; |
| 573 | p->aTag[i].zName = zName; |
| 574 | p->aTag[i].zUuid = zUuid; |
| 575 | p->aTag[i].zValue = zValue; |
| 576 |
+1
-1
| --- src/pqueue.c | ||
| +++ src/pqueue.c | ||
| @@ -62,11 +62,11 @@ | ||
| 62 | 62 | |
| 63 | 63 | /* |
| 64 | 64 | ** Change the size of the queue so that it contains N slots |
| 65 | 65 | */ |
| 66 | 66 | static void pqueue_resize(PQueue *p, int N){ |
| 67 | - p->a = realloc(p->a, sizeof(p->a[0])*N); | |
| 67 | + p->a = fossil_realloc(p->a, sizeof(p->a[0])*N); | |
| 68 | 68 | p->sz = N; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /* |
| 72 | 72 | ** Insert element e into the queue. |
| 73 | 73 |
| --- src/pqueue.c | |
| +++ src/pqueue.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | /* |
| 64 | ** Change the size of the queue so that it contains N slots |
| 65 | */ |
| 66 | static void pqueue_resize(PQueue *p, int N){ |
| 67 | p->a = realloc(p->a, sizeof(p->a[0])*N); |
| 68 | p->sz = N; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | ** Insert element e into the queue. |
| 73 |
| --- src/pqueue.c | |
| +++ src/pqueue.c | |
| @@ -62,11 +62,11 @@ | |
| 62 | |
| 63 | /* |
| 64 | ** Change the size of the queue so that it contains N slots |
| 65 | */ |
| 66 | static void pqueue_resize(PQueue *p, int N){ |
| 67 | p->a = fossil_realloc(p->a, sizeof(p->a[0])*N); |
| 68 | p->sz = N; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | ** Insert element e into the queue. |
| 73 |
+3
-4
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -560,11 +560,11 @@ | ||
| 560 | 560 | int i; |
| 561 | 561 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 562 | 562 | char *e = va_arg(ap,char*); |
| 563 | 563 | if( e==0 ){e="";} |
| 564 | 564 | length = StrNLen32(e, limit); |
| 565 | - zExtra = bufpt = malloc(length+1); | |
| 565 | + zExtra = bufpt = fossil_malloc(length+1); | |
| 566 | 566 | for( i=0; i<length; i++ ){ |
| 567 | 567 | if( e[i]=='\\' ){ |
| 568 | 568 | bufpt[i]='/'; |
| 569 | 569 | }else{ |
| 570 | 570 | bufpt[i]=e[i]; |
| @@ -605,11 +605,11 @@ | ||
| 605 | 605 | int i, j, n, cnt; |
| 606 | 606 | n = blob_size(pBlob); |
| 607 | 607 | if( limit>=0 && limit<n ) n = limit; |
| 608 | 608 | for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; } |
| 609 | 609 | if( n+cnt+2 > etBUFSIZE ){ |
| 610 | - bufpt = zExtra = malloc( n + cnt + 2 ); | |
| 610 | + bufpt = zExtra = fossil_malloc( n + cnt + 2 ); | |
| 611 | 611 | }else{ |
| 612 | 612 | bufpt = buf; |
| 613 | 613 | } |
| 614 | 614 | bufpt[0] = '\''; |
| 615 | 615 | for(i=0, j=1; i<n; i++, j++){ |
| @@ -634,12 +634,11 @@ | ||
| 634 | 634 | if( escarg[i]=='\'' ) n++; |
| 635 | 635 | } |
| 636 | 636 | needQuote = !isnull && xtype==etSQLESCAPE2; |
| 637 | 637 | n += i + 1 + needQuote*2; |
| 638 | 638 | if( n>etBUFSIZE ){ |
| 639 | - bufpt = zExtra = malloc( n ); | |
| 640 | - if( bufpt==0 ) return -1; | |
| 639 | + bufpt = zExtra = fossil_malloc( n ); | |
| 641 | 640 | }else{ |
| 642 | 641 | bufpt = buf; |
| 643 | 642 | } |
| 644 | 643 | j = 0; |
| 645 | 644 | if( needQuote ) bufpt[j++] = '\''; |
| 646 | 645 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -560,11 +560,11 @@ | |
| 560 | int i; |
| 561 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 562 | char *e = va_arg(ap,char*); |
| 563 | if( e==0 ){e="";} |
| 564 | length = StrNLen32(e, limit); |
| 565 | zExtra = bufpt = malloc(length+1); |
| 566 | for( i=0; i<length; i++ ){ |
| 567 | if( e[i]=='\\' ){ |
| 568 | bufpt[i]='/'; |
| 569 | }else{ |
| 570 | bufpt[i]=e[i]; |
| @@ -605,11 +605,11 @@ | |
| 605 | int i, j, n, cnt; |
| 606 | n = blob_size(pBlob); |
| 607 | if( limit>=0 && limit<n ) n = limit; |
| 608 | for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; } |
| 609 | if( n+cnt+2 > etBUFSIZE ){ |
| 610 | bufpt = zExtra = malloc( n + cnt + 2 ); |
| 611 | }else{ |
| 612 | bufpt = buf; |
| 613 | } |
| 614 | bufpt[0] = '\''; |
| 615 | for(i=0, j=1; i<n; i++, j++){ |
| @@ -634,12 +634,11 @@ | |
| 634 | if( escarg[i]=='\'' ) n++; |
| 635 | } |
| 636 | needQuote = !isnull && xtype==etSQLESCAPE2; |
| 637 | n += i + 1 + needQuote*2; |
| 638 | if( n>etBUFSIZE ){ |
| 639 | bufpt = zExtra = malloc( n ); |
| 640 | if( bufpt==0 ) return -1; |
| 641 | }else{ |
| 642 | bufpt = buf; |
| 643 | } |
| 644 | j = 0; |
| 645 | if( needQuote ) bufpt[j++] = '\''; |
| 646 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -560,11 +560,11 @@ | |
| 560 | int i; |
| 561 | int limit = flag_alternateform ? va_arg(ap,int) : -1; |
| 562 | char *e = va_arg(ap,char*); |
| 563 | if( e==0 ){e="";} |
| 564 | length = StrNLen32(e, limit); |
| 565 | zExtra = bufpt = fossil_malloc(length+1); |
| 566 | for( i=0; i<length; i++ ){ |
| 567 | if( e[i]=='\\' ){ |
| 568 | bufpt[i]='/'; |
| 569 | }else{ |
| 570 | bufpt[i]=e[i]; |
| @@ -605,11 +605,11 @@ | |
| 605 | int i, j, n, cnt; |
| 606 | n = blob_size(pBlob); |
| 607 | if( limit>=0 && limit<n ) n = limit; |
| 608 | for(cnt=i=0; i<n; i++){ if( zOrig[i]=='\'' ) cnt++; } |
| 609 | if( n+cnt+2 > etBUFSIZE ){ |
| 610 | bufpt = zExtra = fossil_malloc( n + cnt + 2 ); |
| 611 | }else{ |
| 612 | bufpt = buf; |
| 613 | } |
| 614 | bufpt[0] = '\''; |
| 615 | for(i=0, j=1; i<n; i++, j++){ |
| @@ -634,12 +634,11 @@ | |
| 634 | if( escarg[i]=='\'' ) n++; |
| 635 | } |
| 636 | needQuote = !isnull && xtype==etSQLESCAPE2; |
| 637 | n += i + 1 + needQuote*2; |
| 638 | if( n>etBUFSIZE ){ |
| 639 | bufpt = zExtra = fossil_malloc( n ); |
| 640 | }else{ |
| 641 | bufpt = buf; |
| 642 | } |
| 643 | j = 0; |
| 644 | if( needQuote ) bufpt[j++] = '\''; |
| 645 |
+1
-2
| --- src/search.c | ||
| +++ src/search.c | ||
| @@ -42,12 +42,11 @@ | ||
| 42 | 42 | int nPattern = strlen(zPattern); |
| 43 | 43 | Search *p; |
| 44 | 44 | char *z; |
| 45 | 45 | int i; |
| 46 | 46 | |
| 47 | - p = malloc( nPattern + sizeof(*p) + 1); | |
| 48 | - if( p==0 ) fossil_panic("out of memory"); | |
| 47 | + p = fossil_malloc( nPattern + sizeof(*p) + 1); | |
| 49 | 48 | z = (char*)&p[1]; |
| 50 | 49 | strcpy(z, zPattern); |
| 51 | 50 | memset(p, 0, sizeof(*p)); |
| 52 | 51 | while( *z && p->nTerm<sizeof(p->a)/sizeof(p->a[0]) ){ |
| 53 | 52 | while( !fossil_isalnum(*z) && *z ){ z++; } |
| 54 | 53 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -42,12 +42,11 @@ | |
| 42 | int nPattern = strlen(zPattern); |
| 43 | Search *p; |
| 44 | char *z; |
| 45 | int i; |
| 46 | |
| 47 | p = malloc( nPattern + sizeof(*p) + 1); |
| 48 | if( p==0 ) fossil_panic("out of memory"); |
| 49 | z = (char*)&p[1]; |
| 50 | strcpy(z, zPattern); |
| 51 | memset(p, 0, sizeof(*p)); |
| 52 | while( *z && p->nTerm<sizeof(p->a)/sizeof(p->a[0]) ){ |
| 53 | while( !fossil_isalnum(*z) && *z ){ z++; } |
| 54 |
| --- src/search.c | |
| +++ src/search.c | |
| @@ -42,12 +42,11 @@ | |
| 42 | int nPattern = strlen(zPattern); |
| 43 | Search *p; |
| 44 | char *z; |
| 45 | int i; |
| 46 | |
| 47 | p = fossil_malloc( nPattern + sizeof(*p) + 1); |
| 48 | z = (char*)&p[1]; |
| 49 | strcpy(z, zPattern); |
| 50 | memset(p, 0, sizeof(*p)); |
| 51 | while( *z && p->nTerm<sizeof(p->a)/sizeof(p->a[0]) ){ |
| 52 | while( !fossil_isalnum(*z) && *z ){ z++; } |
| 53 |
+1
-1
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -30,11 +30,11 @@ | ||
| 30 | 30 | |
| 31 | 31 | /* |
| 32 | 32 | ** Implementations of malloc() and free() to pass to the interpreter. |
| 33 | 33 | */ |
| 34 | 34 | static void *xMalloc(unsigned int n){ |
| 35 | - void *p = malloc(n); | |
| 35 | + void *p = fossil_malloc(n); | |
| 36 | 36 | if( p ){ |
| 37 | 37 | nOutstandingMalloc++; |
| 38 | 38 | } |
| 39 | 39 | return p; |
| 40 | 40 | } |
| 41 | 41 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -30,11 +30,11 @@ | |
| 30 | |
| 31 | /* |
| 32 | ** Implementations of malloc() and free() to pass to the interpreter. |
| 33 | */ |
| 34 | static void *xMalloc(unsigned int n){ |
| 35 | void *p = malloc(n); |
| 36 | if( p ){ |
| 37 | nOutstandingMalloc++; |
| 38 | } |
| 39 | return p; |
| 40 | } |
| 41 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -30,11 +30,11 @@ | |
| 30 | |
| 31 | /* |
| 32 | ** Implementations of malloc() and free() to pass to the interpreter. |
| 33 | */ |
| 34 | static void *xMalloc(unsigned int n){ |
| 35 | void *p = fossil_malloc(n); |
| 36 | if( p ){ |
| 37 | nOutstandingMalloc++; |
| 38 | } |
| 39 | return p; |
| 40 | } |
| 41 |
+1
-4
| --- src/tkt.c | ||
| +++ src/tkt.c | ||
| @@ -53,14 +53,11 @@ | ||
| 53 | 53 | db_prepare(&q, "PRAGMA table_info(ticket)"); |
| 54 | 54 | while( db_step(&q)==SQLITE_ROW ){ |
| 55 | 55 | const char *zField = db_column_text(&q, 1); |
| 56 | 56 | if( strncmp(zField,"tkt_",4)==0 ) continue; |
| 57 | 57 | if( nField%10==0 ){ |
| 58 | - azField = realloc(azField, sizeof(azField)*3*(nField+10) ); | |
| 59 | - if( azField==0 ){ | |
| 60 | - fossil_fatal("out of memory"); | |
| 61 | - } | |
| 58 | + azField = fossil_realloc(azField, sizeof(azField)*3*(nField+10) ); | |
| 62 | 59 | } |
| 63 | 60 | azField[nField] = mprintf("%s", zField); |
| 64 | 61 | nField++; |
| 65 | 62 | } |
| 66 | 63 | db_finalize(&q); |
| 67 | 64 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -53,14 +53,11 @@ | |
| 53 | db_prepare(&q, "PRAGMA table_info(ticket)"); |
| 54 | while( db_step(&q)==SQLITE_ROW ){ |
| 55 | const char *zField = db_column_text(&q, 1); |
| 56 | if( strncmp(zField,"tkt_",4)==0 ) continue; |
| 57 | if( nField%10==0 ){ |
| 58 | azField = realloc(azField, sizeof(azField)*3*(nField+10) ); |
| 59 | if( azField==0 ){ |
| 60 | fossil_fatal("out of memory"); |
| 61 | } |
| 62 | } |
| 63 | azField[nField] = mprintf("%s", zField); |
| 64 | nField++; |
| 65 | } |
| 66 | db_finalize(&q); |
| 67 |
| --- src/tkt.c | |
| +++ src/tkt.c | |
| @@ -53,14 +53,11 @@ | |
| 53 | db_prepare(&q, "PRAGMA table_info(ticket)"); |
| 54 | while( db_step(&q)==SQLITE_ROW ){ |
| 55 | const char *zField = db_column_text(&q, 1); |
| 56 | if( strncmp(zField,"tkt_",4)==0 ) continue; |
| 57 | if( nField%10==0 ){ |
| 58 | azField = fossil_realloc(azField, sizeof(azField)*3*(nField+10) ); |
| 59 | } |
| 60 | azField[nField] = mprintf("%s", zField); |
| 61 | nField++; |
| 62 | } |
| 63 | db_finalize(&q); |
| 64 |
+1
-4
| --- src/wikiformat.c | ||
| +++ src/wikiformat.c | ||
| @@ -838,14 +838,11 @@ | ||
| 838 | 838 | ** if necessary. |
| 839 | 839 | */ |
| 840 | 840 | static void pushStackWithId(Renderer *p, int elem, const char *zId, int w){ |
| 841 | 841 | if( p->nStack>=p->nAlloc ){ |
| 842 | 842 | p->nAlloc = p->nAlloc*2 + 100; |
| 843 | - p->aStack = realloc(p->aStack, p->nAlloc*sizeof(p->aStack[0])); | |
| 844 | - if( p->aStack==0 ){ | |
| 845 | - fossil_panic("out of memory"); | |
| 846 | - } | |
| 843 | + p->aStack = fossil_realloc(p->aStack, p->nAlloc*sizeof(p->aStack[0])); | |
| 847 | 844 | } |
| 848 | 845 | p->aStack[p->nStack].iCode = elem; |
| 849 | 846 | p->aStack[p->nStack].zId = zId; |
| 850 | 847 | p->aStack[p->nStack].allowWiki = w; |
| 851 | 848 | p->nStack++; |
| 852 | 849 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -838,14 +838,11 @@ | |
| 838 | ** if necessary. |
| 839 | */ |
| 840 | static void pushStackWithId(Renderer *p, int elem, const char *zId, int w){ |
| 841 | if( p->nStack>=p->nAlloc ){ |
| 842 | p->nAlloc = p->nAlloc*2 + 100; |
| 843 | p->aStack = realloc(p->aStack, p->nAlloc*sizeof(p->aStack[0])); |
| 844 | if( p->aStack==0 ){ |
| 845 | fossil_panic("out of memory"); |
| 846 | } |
| 847 | } |
| 848 | p->aStack[p->nStack].iCode = elem; |
| 849 | p->aStack[p->nStack].zId = zId; |
| 850 | p->aStack[p->nStack].allowWiki = w; |
| 851 | p->nStack++; |
| 852 |
| --- src/wikiformat.c | |
| +++ src/wikiformat.c | |
| @@ -838,14 +838,11 @@ | |
| 838 | ** if necessary. |
| 839 | */ |
| 840 | static void pushStackWithId(Renderer *p, int elem, const char *zId, int w){ |
| 841 | if( p->nStack>=p->nAlloc ){ |
| 842 | p->nAlloc = p->nAlloc*2 + 100; |
| 843 | p->aStack = fossil_realloc(p->aStack, p->nAlloc*sizeof(p->aStack[0])); |
| 844 | } |
| 845 | p->aStack[p->nStack].iCode = elem; |
| 846 | p->aStack[p->nStack].zId = zId; |
| 847 | p->aStack[p->nStack].allowWiki = w; |
| 848 | p->nStack++; |
| 849 |
+1
-4
| --- src/winhttp.c | ||
| +++ src/winhttp.c | ||
| @@ -207,14 +207,11 @@ | ||
| 207 | 207 | } |
| 208 | 208 | if( client==INVALID_SOCKET ){ |
| 209 | 209 | closesocket(s); |
| 210 | 210 | fossil_fatal("error from accept()"); |
| 211 | 211 | } |
| 212 | - p = malloc( sizeof(*p) ); | |
| 213 | - if( p==0 ){ | |
| 214 | - fossil_fatal("out of memory"); | |
| 215 | - } | |
| 212 | + p = fossil_malloc( sizeof(*p) ); | |
| 216 | 213 | p->id = ++idCnt; |
| 217 | 214 | p->s = client; |
| 218 | 215 | p->addr = client_addr; |
| 219 | 216 | p->zNotFound = zNotFoundOption; |
| 220 | 217 | _beginthread(win32_process_one_http_request, 0, (void*)p); |
| 221 | 218 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -207,14 +207,11 @@ | |
| 207 | } |
| 208 | if( client==INVALID_SOCKET ){ |
| 209 | closesocket(s); |
| 210 | fossil_fatal("error from accept()"); |
| 211 | } |
| 212 | p = malloc( sizeof(*p) ); |
| 213 | if( p==0 ){ |
| 214 | fossil_fatal("out of memory"); |
| 215 | } |
| 216 | p->id = ++idCnt; |
| 217 | p->s = client; |
| 218 | p->addr = client_addr; |
| 219 | p->zNotFound = zNotFoundOption; |
| 220 | _beginthread(win32_process_one_http_request, 0, (void*)p); |
| 221 |
| --- src/winhttp.c | |
| +++ src/winhttp.c | |
| @@ -207,14 +207,11 @@ | |
| 207 | } |
| 208 | if( client==INVALID_SOCKET ){ |
| 209 | closesocket(s); |
| 210 | fossil_fatal("error from accept()"); |
| 211 | } |
| 212 | p = fossil_malloc( sizeof(*p) ); |
| 213 | p->id = ++idCnt; |
| 214 | p->s = client; |
| 215 | p->addr = client_addr; |
| 216 | p->zNotFound = zNotFoundOption; |
| 217 | _beginthread(win32_process_one_http_request, 0, (void*)p); |
| 218 |
+1
-1
| --- src/zip.c | ||
| +++ src/zip.c | ||
| @@ -102,11 +102,11 @@ | ||
| 102 | 102 | for(j=0; j<nDir; j++){ |
| 103 | 103 | if( strcmp(zName, azDir[j])==0 ) break; |
| 104 | 104 | } |
| 105 | 105 | if( j>=nDir ){ |
| 106 | 106 | nDir++; |
| 107 | - azDir = realloc(azDir, sizeof(azDir[0])*nDir); | |
| 107 | + azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir); | |
| 108 | 108 | azDir[j] = mprintf("%s", zName); |
| 109 | 109 | zip_add_file(zName, 0); |
| 110 | 110 | } |
| 111 | 111 | zName[i+1] = c; |
| 112 | 112 | } |
| 113 | 113 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -102,11 +102,11 @@ | |
| 102 | for(j=0; j<nDir; j++){ |
| 103 | if( strcmp(zName, azDir[j])==0 ) break; |
| 104 | } |
| 105 | if( j>=nDir ){ |
| 106 | nDir++; |
| 107 | azDir = realloc(azDir, sizeof(azDir[0])*nDir); |
| 108 | azDir[j] = mprintf("%s", zName); |
| 109 | zip_add_file(zName, 0); |
| 110 | } |
| 111 | zName[i+1] = c; |
| 112 | } |
| 113 |
| --- src/zip.c | |
| +++ src/zip.c | |
| @@ -102,11 +102,11 @@ | |
| 102 | for(j=0; j<nDir; j++){ |
| 103 | if( strcmp(zName, azDir[j])==0 ) break; |
| 104 | } |
| 105 | if( j>=nDir ){ |
| 106 | nDir++; |
| 107 | azDir = fossil_realloc(azDir, sizeof(azDir[0])*nDir); |
| 108 | azDir[j] = mprintf("%s", zName); |
| 109 | zip_add_file(zName, 0); |
| 110 | } |
| 111 | zName[i+1] = c; |
| 112 | } |
| 113 |