rem: low = index + 1;
add: low = ++index;
context: atomize(const void * at, const char *string, int create) {	atomizer_data_list *adl;	void *result = 0;	uint32	len;	/* NULL and zero length strings aren't interned */	if (!string || !(len = strlen(string))) return 0;	/* include the null terminator */	len++;	/* own the list or fail trying */	ACQUIRE_BEN_ON_ERROR(module_lock, return 0);	/* use the system atomizer if none specified */	if (at == ((void *)(-1))) at = atomizer_list->the_atomizer;	/* walk the list of known atomizers, looking for a match */	adl = atomizer_list;	while (adl && (adl->the_atomizer != (atomizer_data *)at)) {		adl = adl->next;	}	/* lock the atomizer *before* we give up control over the list */	if (adl) ACQUIRE_BEN(adl->the_atomizer->lock);	/* allow list manipulations */	RELEASE_BEN(module_lock);	/* did we find the one we wanted? */	if (adl) {		atomizer_data *ad = adl->the_atomizer;		uint8 **vector = ad->vector;		uint32 count = ad->count;		uint32 low = 0;		uint32 high = count;		uint32 index = 0;		int test = -1;		/* do a binary search on the vector for a match */		while (low < high) {			index = (low + high) / 2;			test = strcmp(string, (const char *)vector[index]);			if (test < 0)				high = index;			else if (test > 0)				low = index + 1;			else				break;		}		/* if match found, note result and return it */		if (test == 0) {			result = vector[index];		} else {			/* if we're not "just checking" */			if (create) {				/* no match, so add to list */				/* find first block with enough room */				block_list *bl = ad->blocks;				while (bl->next) {					if (bl->free_bytes >= len) break;					bl = bl->next;				}				if (bl->free_bytes < len) {					/* allocate a block big enough to handle the string */					size_t block_size = ((sizeof(block_list)+len+(MIN_BLOCK_SIZE-1)) & ~(MIN_BLOCK_SIZE-1));					bl->next = (block_list *)malloc(block_size);					if (!bl->next) {						RELEASE_BEN(ad->lock);						return 0;					}					bl = bl->next;					bl->free_space = (uint8 *)(bl+1);					bl->free_bytes = block_size - sizeof(block_list);				}				/* actually intern an atom */				result = bl->free_space;				memcpy(result, string, len);				bl->free_space += len;				bl->free_bytes -= len;								/* insert the pointer in the vector */				/* if the vector isn't big enough, realloc it */				if (ad->count == ad->slots) {					size_t newslots = ad->slots + (MIN_BLOCK_SIZE / sizeof(uint8 *));					uint8 **newvec = realloc(vector, newslots * sizeof(uint8 *));					if (!newvec) {						/* bail, leaving the atom un-interned */						RELEASE_BEN(ad->lock);						return 0;					}					ad->slots = newslots;					vector = ad->vector = newvec;				}				/* move all of the entries starting at index down one slot */				memmove(vector + index + 1, vector + index, (count - index) * sizeof(uint8 *));				/* insert the new pointer in the vector */				vector[index] = result;				/* note new count */				ad->count++;			}		}		RELEASE_BEN(ad->lock);	}	return result;}