Changeset 1997 in kBuild
- Timestamp:
- Oct 29, 2008 9:31:35 PM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/function.c
r1993 r1997 1040 1040 free (result); 1041 1041 #else /* CONFIG_WITH_VALUE_LENGTH */ 1042 if (len >= (unsigned int)var->value_alloc_len)1042 if (len >= var->value_alloc_len) 1043 1043 { 1044 1044 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE … … 1048 1048 # endif 1049 1049 free (var->value); 1050 var->value_alloc_len = (len + 32) & ~31;1050 var->value_alloc_len = VAR_ALIGN_VALUE_ALLOC (len + 1); 1051 1051 var->value = xmalloc (var->value_alloc_len); 1052 1052 } -
trunk/src/kmk/variable.c
r1993 r1997 260 260 free (v->value); 261 261 v->rdonly_val = duplicate_value == -1; 262 v->value = (char *) value;262 v->value = (char *) value; 263 263 v->value_alloc_len = 0; 264 264 # else 265 265 if (v->value != 0) 266 266 free (v->value); 267 v->value = (char *) value;267 v->value = (char *) value; 268 268 v->value_alloc_len = value_len + 1; 269 269 # endif … … 271 271 else 272 272 { 273 if ( (unsigned int)v->value_alloc_len <= value_len)273 if (v->value_alloc_len <= value_len) 274 274 { 275 275 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE … … 279 279 # endif 280 280 free (v->value); 281 v->value_alloc_len = (value_len + 0x40) & ~0x3f;281 v->value_alloc_len = VAR_ALIGN_VALUE_ALLOC (value_len + 1); 282 282 v->value = xmalloc (v->value_alloc_len); 283 283 } … … 333 333 v->rdonly_val = 0; 334 334 # endif 335 v->value_alloc_len = (value_len + 32) & ~31;335 v->value_alloc_len = VAR_ALIGN_VALUE_ALLOC (value_len + 1); 336 336 v->value = xmalloc (v->value_alloc_len); 337 337 memcpy (v->value, value, value_len + 1); 338 338 } 339 #else 339 #else /* !CONFIG_WITH_VALUE_LENGTH */ 340 340 v->value = xstrdup (value); 341 #endif 341 #endif /* !CONFIG_WITH_VALUE_LENGTH */ 342 342 if (flocp != 0) 343 343 v->fileinfo = *flocp; … … 1632 1632 1633 1633 /* adjust the size. */ 1634 if ( (unsigned)v->value_alloc_len <= new_value_len + 1)1634 if (v->value_alloc_len <= new_value_len + 1) 1635 1635 { 1636 1636 v->value_alloc_len *= 2; 1637 if ( (unsigned)v->value_alloc_len < new_value_len + 1)1638 v->value_alloc_len = (new_value_len + 1 + value_len + 0x7f) + ~0x7fU;1637 if (v->value_alloc_len < new_value_len + 1) 1638 v->value_alloc_len = VAR_ALIGN_VALUE_ALLOC (new_value_len + 1 + value_len + 1); 1639 1639 # ifdef CONFIG_WITH_RDONLY_VARIABLE_VALUE 1640 1640 if ((append || !v->value_length) && !v->rdonly_val) … … 2188 2188 v->value = p; 2189 2189 #ifdef CONFIG_WITH_VALUE_LENGTH 2190 v->value_alloc_len = -1;2190 v->value_alloc_len = ~(unsigned int)0; 2191 2191 v->value_length = eos != NULL ? eos - p : -1; 2192 2192 assert (eos == NULL || strchr (p, '\0') == eos); -
trunk/src/kmk/variable.h
r1993 r1997 54 54 #define EXP_COUNT_BITS 15 /* This gets all the bitfields into 32 bits */ 55 55 #define EXP_COUNT_MAX ((1<<EXP_COUNT_BITS)-1) 56 #ifdef CONFIG_WITH_VALUE_LENGTH 57 #define VAR_ALIGN_VALUE_ALLOC(len) ( ((len) + (unsigned int)31) & ~(unsigned int)31 ) 58 #endif 56 59 57 60 struct variable … … 65 68 #ifdef CONFIG_WITH_VALUE_LENGTH 66 69 int value_length; /* The length of the value, usually unused. */ 67 int value_alloc_len;/* The amount of memory we've actually allocated. */70 unsigned int value_alloc_len; /* The amount of memory we've actually allocated. */ 68 71 /* FIXME: make lengths unsigned! */ 69 72 #endif
Note:
See TracChangeset
for help on using the changeset viewer.