/* Each attribute is stored as a record: sizeof(int) bytes record size. yaffs_strnlen+1 bytes name null terminated.  */
static int nval_find(const char *xb, int xb_size, const YCHAR *name, int *exist_size)
/* Each attribute is stored as a record: sizeof(int) bytes record size. yaffs_strnlen+1 bytes name null terminated.  */
static int nval_find(const char *xb, int xb_size, const YCHAR *name, int *exist_size)
{
	int pos = 0;
	int size;
	memcpy(&size, xb, sizeof(int));
	while (size > 0 && (size < xb_size) && (pos + size < xb_size)) {
		if (!yaffs_strncmp((YCHAR *) (xb + pos + sizeof(int)),
				name, size)) {
			if (exist_size)
				*exist_size = size;
			return pos;
		}
		pos += size;
		if (pos < xb_size - sizeof(int))
			memcpy(&size, xb + pos, sizeof(int));
		else
			size = 0;
	}
	if (exist_size)
		*exist_size = 0;
	return -ENODATA;
}