Changeset 1843 in kBuild for trunk/src/kmk
- Timestamp:
- Oct 12, 2008 3:40:32 PM (16 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/make.h
r1842 r1843 504 504 const char *strcache_add_len (const char *str, int len); 505 505 int strcache_setbufsize (int size); 506 #ifdef CONFIG_WITH_VALUE_LENGTH 507 MY_INLINE unsigned int strcache_get_len (const char *str) 508 { 509 unsigned int len = ((unsigned int *)str)[-1]; 510 MY_ASSERT_MSG (strcache_iscached (str), ("\n")); 511 MY_ASSERT_MSG (strlen (str) == len, ("\n")); 512 return len; 513 } 514 #endif 506 515 507 516 #ifdef HAVE_VFORK_H -
trunk/src/kmk/strcache.c
r1793 r1843 67 67 struct strcache *sp; 68 68 const char *res; 69 #ifdef CONFIG_WITH_VALUE_LENGTH 70 int str_len = len; 71 char *tmp; 72 73 /* Add space a length prefix and the terminator and assure 74 (somewhat) natural alignment. */ 75 len += sizeof(unsigned int) + 1; 76 len = (len + sizeof(void *) - 1) & ~(sizeof(void *) - 1); 77 --len; 78 #endif 69 79 70 80 /* If the string we want is too large to fit into a single buffer, then … … 88 98 89 99 /* Add the string to the best cache. */ 100 #ifndef CONFIG_WITH_VALUE_LENGTH 90 101 res = best->end; 91 102 memcpy (best->end, str, len); … … 94 105 best->bytesfree -= len + 1; 95 106 ++best->count; 96 107 #else /* CONFIG_WITH_VALUE_LENGTH */ 108 tmp = best->end; 109 best->end += len + 1; 110 assert(!((size_t)tmp & (sizeof(void *) - 1))); 111 112 *(unsigned int *)tmp = str_len; /* length prefix */ 113 tmp += sizeof(unsigned int); 114 115 res = tmp; 116 memcpy (tmp, str, str_len); 117 tmp += str_len; 118 do 119 *(tmp++) = '\0'; 120 while (tmp < best->end); 121 122 best->bytesfree -= len + 1; 123 ++best->count; 124 125 assert (tmp == best->end); 126 assert (!((size_t)res & (sizeof(void *) - 1))); 127 #endif /* CONFIG_WITH_VALUE_LENGTH */ 97 128 return res; 98 129 }
Note:
See TracChangeset
for help on using the changeset viewer.