Fossil SCM

latest cson code - minor gcc 4.6 portability fixes only.

stephan 2012-02-18 22:56 trunk
Commit f32b042eed87c2e73792e6ec7219415dbc0a8864
1 file changed +8 -12
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -2200,14 +2200,13 @@
22002200
# define VALUE_T_IS_PTR 1
22012201
#else
22022202
#endif
22032203
22042204
/**
2205
- Allocates a new value of the specified type ownership of it to the
2206
- caller. It must eventually be destroyed, by the caller or its
2207
- owning container, by passing it to cson_value_free() or transfering
2208
- ownership to a container.
2205
+ Allocates a new value of the specified type. Ownership is
2206
+ transfered to the caller, who must eventually free it by passing it
2207
+ to cson_value_free() or transfering ownership to a container.
22092208
22102209
extra is only valid for type CSON_TYPE_STRING, and must be the length
22112210
of the string to allocate + 1 byte (for the NUL).
22122211
22132212
The returned value->api member will be set appropriately and
@@ -2249,10 +2248,15 @@
22492248
tx = sizeof(cson_double_t);
22502249
reason = "cson_value:double";
22512250
break;
22522251
case CSON_TYPE_INTEGER:
22532252
assert( 0 == extra );
2253
+ /* FIXME: if sizeof(void*) >= sizeof(cson_int_t) then store
2254
+ the int value directly in the void pointer (requires no
2255
+ extra alloc). The current behaviour requires 32
2256
+ bytes(!!!) on 64-bit builds.
2257
+ */
22542258
def = cson_value_integer_empty;
22552259
tx = sizeof(cson_int_t);
22562260
reason = "cson_value:int";
22572261
break;
22582262
case CSON_TYPE_STRING:
@@ -2281,11 +2285,10 @@
22812285
}
22822286
}
22832287
return v;
22842288
}
22852289
2286
-
22872290
void cson_value_free(cson_value *v)
22882291
{
22892292
cson_refcount_decr( v );
22902293
}
22912294
@@ -2304,15 +2307,10 @@
23042307
}
23052308
#endif
23062309
23072310
char cson_value_is_undef( cson_value const * v )
23082311
{
2309
- /**
2310
- This special-case impl is needed because the underlying
2311
- (generic) list operations do not know how to populate
2312
- new entries
2313
- */
23142312
return ( !v || !v->api || (v->api==&cson_value_api_undef))
23152313
? 1 : 0;
23162314
}
23172315
#define ISA(T,TID) char cson_value_is_##T( cson_value const * v ) { \
23182316
/*return (v && v->api) ? cson_value_is_a(v,CSON_TYPE_##TID) : 0;*/ \
@@ -5504,11 +5502,10 @@
55045502
else
55055503
{
55065504
cson_value * rootV = NULL;
55075505
cson_object * root = NULL;
55085506
cson_value * aryV = NULL;
5509
- cson_array * ary = NULL;
55105507
cson_value * rowsV = NULL;
55115508
cson_array * rows = NULL;
55125509
int rc = 0;
55135510
int const colCount = sqlite3_column_count(st);
55145511
if( colCount <= 0 ) return cson_rc.ArgError;
@@ -5526,11 +5523,10 @@
55265523
{
55275524
cson_value_free( aryV );
55285525
RETURN(rc);
55295526
}
55305527
aryV = NULL;
5531
- ary = NULL;
55325528
rowsV = cson_value_new_array();
55335529
if( ! rowsV ) RETURN(cson_rc.AllocError);
55345530
rc = cson_object_set( root, "rows", rowsV );
55355531
if( 0 != rc )
55365532
{
55375533
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -2200,14 +2200,13 @@
2200 # define VALUE_T_IS_PTR 1
2201 #else
2202 #endif
2203
2204 /**
2205 Allocates a new value of the specified type ownership of it to the
2206 caller. It must eventually be destroyed, by the caller or its
2207 owning container, by passing it to cson_value_free() or transfering
2208 ownership to a container.
2209
2210 extra is only valid for type CSON_TYPE_STRING, and must be the length
2211 of the string to allocate + 1 byte (for the NUL).
2212
2213 The returned value->api member will be set appropriately and
@@ -2249,10 +2248,15 @@
2249 tx = sizeof(cson_double_t);
2250 reason = "cson_value:double";
2251 break;
2252 case CSON_TYPE_INTEGER:
2253 assert( 0 == extra );
 
 
 
 
 
2254 def = cson_value_integer_empty;
2255 tx = sizeof(cson_int_t);
2256 reason = "cson_value:int";
2257 break;
2258 case CSON_TYPE_STRING:
@@ -2281,11 +2285,10 @@
2281 }
2282 }
2283 return v;
2284 }
2285
2286
2287 void cson_value_free(cson_value *v)
2288 {
2289 cson_refcount_decr( v );
2290 }
2291
@@ -2304,15 +2307,10 @@
2304 }
2305 #endif
2306
2307 char cson_value_is_undef( cson_value const * v )
2308 {
2309 /**
2310 This special-case impl is needed because the underlying
2311 (generic) list operations do not know how to populate
2312 new entries
2313 */
2314 return ( !v || !v->api || (v->api==&cson_value_api_undef))
2315 ? 1 : 0;
2316 }
2317 #define ISA(T,TID) char cson_value_is_##T( cson_value const * v ) { \
2318 /*return (v && v->api) ? cson_value_is_a(v,CSON_TYPE_##TID) : 0;*/ \
@@ -5504,11 +5502,10 @@
5504 else
5505 {
5506 cson_value * rootV = NULL;
5507 cson_object * root = NULL;
5508 cson_value * aryV = NULL;
5509 cson_array * ary = NULL;
5510 cson_value * rowsV = NULL;
5511 cson_array * rows = NULL;
5512 int rc = 0;
5513 int const colCount = sqlite3_column_count(st);
5514 if( colCount <= 0 ) return cson_rc.ArgError;
@@ -5526,11 +5523,10 @@
5526 {
5527 cson_value_free( aryV );
5528 RETURN(rc);
5529 }
5530 aryV = NULL;
5531 ary = NULL;
5532 rowsV = cson_value_new_array();
5533 if( ! rowsV ) RETURN(cson_rc.AllocError);
5534 rc = cson_object_set( root, "rows", rowsV );
5535 if( 0 != rc )
5536 {
5537
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -2200,14 +2200,13 @@
2200 # define VALUE_T_IS_PTR 1
2201 #else
2202 #endif
2203
2204 /**
2205 Allocates a new value of the specified type. Ownership is
2206 transfered to the caller, who must eventually free it by passing it
2207 to cson_value_free() or transfering ownership to a container.
 
2208
2209 extra is only valid for type CSON_TYPE_STRING, and must be the length
2210 of the string to allocate + 1 byte (for the NUL).
2211
2212 The returned value->api member will be set appropriately and
@@ -2249,10 +2248,15 @@
2248 tx = sizeof(cson_double_t);
2249 reason = "cson_value:double";
2250 break;
2251 case CSON_TYPE_INTEGER:
2252 assert( 0 == extra );
2253 /* FIXME: if sizeof(void*) >= sizeof(cson_int_t) then store
2254 the int value directly in the void pointer (requires no
2255 extra alloc). The current behaviour requires 32
2256 bytes(!!!) on 64-bit builds.
2257 */
2258 def = cson_value_integer_empty;
2259 tx = sizeof(cson_int_t);
2260 reason = "cson_value:int";
2261 break;
2262 case CSON_TYPE_STRING:
@@ -2281,11 +2285,10 @@
2285 }
2286 }
2287 return v;
2288 }
2289
 
2290 void cson_value_free(cson_value *v)
2291 {
2292 cson_refcount_decr( v );
2293 }
2294
@@ -2304,15 +2307,10 @@
2307 }
2308 #endif
2309
2310 char cson_value_is_undef( cson_value const * v )
2311 {
 
 
 
 
 
2312 return ( !v || !v->api || (v->api==&cson_value_api_undef))
2313 ? 1 : 0;
2314 }
2315 #define ISA(T,TID) char cson_value_is_##T( cson_value const * v ) { \
2316 /*return (v && v->api) ? cson_value_is_a(v,CSON_TYPE_##TID) : 0;*/ \
@@ -5504,11 +5502,10 @@
5502 else
5503 {
5504 cson_value * rootV = NULL;
5505 cson_object * root = NULL;
5506 cson_value * aryV = NULL;
 
5507 cson_value * rowsV = NULL;
5508 cson_array * rows = NULL;
5509 int rc = 0;
5510 int const colCount = sqlite3_column_count(st);
5511 if( colCount <= 0 ) return cson_rc.ArgError;
@@ -5526,11 +5523,10 @@
5523 {
5524 cson_value_free( aryV );
5525 RETURN(rc);
5526 }
5527 aryV = NULL;
 
5528 rowsV = cson_value_new_array();
5529 if( ! rowsV ) RETURN(cson_rc.AllocError);
5530 rc = cson_object_set( root, "rows", rowsV );
5531 if( 0 != rc )
5532 {
5533

Keyboard Shortcuts

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