- Timestamp:
- Sep 19, 2010, 2:23:16 AM (15 years ago)
- Location:
- trunk/emx/src/emxomf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/emx/src/emxomf/grow.c
r492 r3669 37 37 #include <string.h> 38 38 #include <ctype.h> 39 #include <assert.h> 39 40 #include "defs.h" 40 41 #include "grow.h" … … 250 251 { 251 252 struct string *next; /* Pointer to next string in same bucket */ 253 int len; /* The string length. */ 252 254 char string[1]; /* The string */ 253 255 }; … … 310 312 hash %= STRPOOL_HASH_SIZE; 311 313 for (v = p->table[hash]; v != NULL; v = v->next) 312 if ( strlen (v->string)== len && memcmp (v->string, s, len) == 0)314 if (v->len == len && memcmp (v->string, s, len) == 0) 313 315 return v->string; 314 316 v = xmalloc (sizeof (*v) + len); 317 assert(((uintptr_t)v & (sizeof(int) - 1)) == 0); 315 318 memcpy (v->string, s, len); 316 319 v->string[len] = 0; 320 v->len = len; 317 321 v->next = p->table[hash]; 318 322 p->table[hash] = v; … … 348 352 hash %= STRPOOL_HASH_SIZE; 349 353 for (v = p->table[hash]; v != NULL; v = v->next) 350 if (strlen (v->string) == len && memcmp (v->string, s, len) == 0) 351 return v->string; 354 if (v->len == len) 355 { 356 i = len; 357 while (--i >= 0) 358 if (toupper(s[i]) != v->string[i]) 359 break; 360 if (i < 0) 361 return v->string; 362 } 352 363 v = xmalloc (sizeof (*v) + len); 364 assert(((uintptr_t)v & (sizeof(int) - 1)) == 0); 353 365 memcpy (v->string, s, len); 354 366 v->string[len] = 0; 355 strupr(v->string); 367 v->len = len; 368 strupr (v->string); 356 369 v->next = p->table[hash]; 357 370 p->table[hash] = v; … … 369 382 } 370 383 384 /* Get the length of a string pool string. This is very quick since we store 385 the lenght before the string data. */ 386 int strpool_len (const char *s) 387 { 388 assert(((uintptr_t)s & (sizeof(int) - 1)) == 0); 389 if (!s) 390 return 0; 391 return ((size_t *)s)[-1]; 392 } 393 -
trunk/emx/src/emxomf/grow.h
r492 r3669 59 59 const char *strpool_addn (struct strpool *p, const char *s, int len); 60 60 const char *strpool_add (struct strpool *p, const char *s); 61 const char *strpool_addnu ( struct strpool *p, const char *s, int len); 62 const char *strpool_addu ( struct strpool *p, const char *s); 61 const char *strpool_addnu (struct strpool *p, const char *s, int len); 62 const char *strpool_addu (struct strpool *p, const char *s); 63 int strpool_len (const char *s); 64
Note:
See TracChangeset
for help on using the changeset viewer.