Fossil SCM
latest cson code - minor gcc 4.6 portability fixes only.
Commit
f32b042eed87c2e73792e6ec7219415dbc0a8864
Parent
06143581fe32057…
1 file changed
+8
-12
+8
-12
| --- src/cson_amalgamation.c | ||
| +++ src/cson_amalgamation.c | ||
| @@ -2200,14 +2200,13 @@ | ||
| 2200 | 2200 | # define VALUE_T_IS_PTR 1 |
| 2201 | 2201 | #else |
| 2202 | 2202 | #endif |
| 2203 | 2203 | |
| 2204 | 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. | |
| 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. | |
| 2209 | 2208 | |
| 2210 | 2209 | extra is only valid for type CSON_TYPE_STRING, and must be the length |
| 2211 | 2210 | of the string to allocate + 1 byte (for the NUL). |
| 2212 | 2211 | |
| 2213 | 2212 | The returned value->api member will be set appropriately and |
| @@ -2249,10 +2248,15 @@ | ||
| 2249 | 2248 | tx = sizeof(cson_double_t); |
| 2250 | 2249 | reason = "cson_value:double"; |
| 2251 | 2250 | break; |
| 2252 | 2251 | case CSON_TYPE_INTEGER: |
| 2253 | 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 | + */ | |
| 2254 | 2258 | def = cson_value_integer_empty; |
| 2255 | 2259 | tx = sizeof(cson_int_t); |
| 2256 | 2260 | reason = "cson_value:int"; |
| 2257 | 2261 | break; |
| 2258 | 2262 | case CSON_TYPE_STRING: |
| @@ -2281,11 +2285,10 @@ | ||
| 2281 | 2285 | } |
| 2282 | 2286 | } |
| 2283 | 2287 | return v; |
| 2284 | 2288 | } |
| 2285 | 2289 | |
| 2286 | - | |
| 2287 | 2290 | void cson_value_free(cson_value *v) |
| 2288 | 2291 | { |
| 2289 | 2292 | cson_refcount_decr( v ); |
| 2290 | 2293 | } |
| 2291 | 2294 | |
| @@ -2304,15 +2307,10 @@ | ||
| 2304 | 2307 | } |
| 2305 | 2308 | #endif |
| 2306 | 2309 | |
| 2307 | 2310 | char cson_value_is_undef( cson_value const * v ) |
| 2308 | 2311 | { |
| 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 | 2312 | return ( !v || !v->api || (v->api==&cson_value_api_undef)) |
| 2315 | 2313 | ? 1 : 0; |
| 2316 | 2314 | } |
| 2317 | 2315 | #define ISA(T,TID) char cson_value_is_##T( cson_value const * v ) { \ |
| 2318 | 2316 | /*return (v && v->api) ? cson_value_is_a(v,CSON_TYPE_##TID) : 0;*/ \ |
| @@ -5504,11 +5502,10 @@ | ||
| 5504 | 5502 | else |
| 5505 | 5503 | { |
| 5506 | 5504 | cson_value * rootV = NULL; |
| 5507 | 5505 | cson_object * root = NULL; |
| 5508 | 5506 | cson_value * aryV = NULL; |
| 5509 | - cson_array * ary = NULL; | |
| 5510 | 5507 | cson_value * rowsV = NULL; |
| 5511 | 5508 | cson_array * rows = NULL; |
| 5512 | 5509 | int rc = 0; |
| 5513 | 5510 | int const colCount = sqlite3_column_count(st); |
| 5514 | 5511 | if( colCount <= 0 ) return cson_rc.ArgError; |
| @@ -5526,11 +5523,10 @@ | ||
| 5526 | 5523 | { |
| 5527 | 5524 | cson_value_free( aryV ); |
| 5528 | 5525 | RETURN(rc); |
| 5529 | 5526 | } |
| 5530 | 5527 | aryV = NULL; |
| 5531 | - ary = NULL; | |
| 5532 | 5528 | rowsV = cson_value_new_array(); |
| 5533 | 5529 | if( ! rowsV ) RETURN(cson_rc.AllocError); |
| 5534 | 5530 | rc = cson_object_set( root, "rows", rowsV ); |
| 5535 | 5531 | if( 0 != rc ) |
| 5536 | 5532 | { |
| 5537 | 5533 |
| --- 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 |