Fossil SCM

Replaced a malloc()/free() with fossil_malloc()/free() and removed the corresponding NULL check (fossil_malloc() dies on error).

stephan 2012-07-03 21:07 trunk
Commit 6ad70288d9f49a5e59128a3a5ea99a6125a03d67
1 file changed +2 -3
+2 -3
--- src/json.c
+++ src/json.c
@@ -932,12 +932,11 @@
932932
element. */
933933
cson_value * part = NULL;
934934
char * zPart = NULL;
935935
++rc;
936936
assert( head != p );
937
- zPart = (char*)malloc(len+1);
938
- assert( (zPart != NULL) && "malloc failure" );
937
+ zPart = (char*)fossil_malloc(len+1);
939938
memcpy(zPart, head, len);
940939
zPart[len] = 0;
941940
if(doDeHttp){
942941
dehttpize(zPart);
943942
}
@@ -957,11 +956,11 @@
957956
run before some of the fossil/json bits are initialized,
958957
and fossil_panic() calls into the JSON API.
959958
*/
960959
;
961960
}
962
- free(zPart);
961
+ fossil_free(zPart);
963962
len = 0;
964963
}
965964
if( !*p ){
966965
break;
967966
}
968967
--- src/json.c
+++ src/json.c
@@ -932,12 +932,11 @@
932 element. */
933 cson_value * part = NULL;
934 char * zPart = NULL;
935 ++rc;
936 assert( head != p );
937 zPart = (char*)malloc(len+1);
938 assert( (zPart != NULL) && "malloc failure" );
939 memcpy(zPart, head, len);
940 zPart[len] = 0;
941 if(doDeHttp){
942 dehttpize(zPart);
943 }
@@ -957,11 +956,11 @@
957 run before some of the fossil/json bits are initialized,
958 and fossil_panic() calls into the JSON API.
959 */
960 ;
961 }
962 free(zPart);
963 len = 0;
964 }
965 if( !*p ){
966 break;
967 }
968
--- src/json.c
+++ src/json.c
@@ -932,12 +932,11 @@
932 element. */
933 cson_value * part = NULL;
934 char * zPart = NULL;
935 ++rc;
936 assert( head != p );
937 zPart = (char*)fossil_malloc(len+1);
 
938 memcpy(zPart, head, len);
939 zPart[len] = 0;
940 if(doDeHttp){
941 dehttpize(zPart);
942 }
@@ -957,11 +956,11 @@
956 run before some of the fossil/json bits are initialized,
957 and fossil_panic() calls into the JSON API.
958 */
959 ;
960 }
961 fossil_free(zPart);
962 len = 0;
963 }
964 if( !*p ){
965 break;
966 }
967

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button