|
From: Bruno H. <br...@cl...> - 2005-06-06 19:44:24
|
Sam wrote:
> > Where do you know that a buffer of size 64 will be sufficient, if
> > you don't know about the maximum size of the integers?
>
> I don't - I want I_to_LEbytes() to find that out and return an error
> code if the buffer space is insufficient.
Actually, in bdb.c you are using both cases at the same time: limited-size
integers (re_len > 0) and unlimited size (re_len == 0).
> if you remove memset() from modules/berkeley-db/bdb.c:fill_dbt(), the
> tests will fail.
Sure, because when, say, bitsize = 53,
I_to_LEbytes(obj,bitsize,...)
will fill 53 bits, i.e. 6 bytes and 5 bits. Whereas you are expecting it
to fill 7 bytes. That's why you think you need to clear 7 bytes in advance.
Does this patch work?
*** bdb.c 14 May 2005 13:45:38 -0000 1.86
--- bdb.c 6 Jun 2005 19:41:32 -0000
***************
*** 1040,1047 ****
}
key->ulen = key->size = bytesize;
key->data = my_malloc(bytesize);
! begin_system_call(); memset(key->data,0,bytesize); end_system_call();
! if (I_to_LEbytes(obj,bitsize,(uintB*)key->data))
NOTREACHED; /* there must not be an overflow! */
# if defined(DEBUG)
ASSERT(eql(LEbytes_to_I(bytesize,(uintB*)key->data),obj));
--- 1040,1046 ----
}
key->ulen = key->size = bytesize;
key->data = my_malloc(bytesize);
! if (I_to_LEbytes(obj,8*bytesize,(uintB*)key->data))
NOTREACHED; /* there must not be an overflow! */
# if defined(DEBUG)
ASSERT(eql(LEbytes_to_I(bytesize,(uintB*)key->data),obj));
> what is "8"?
"8" is an arbitrary number occurring in the specification of the
I_to_LEbytes function.
Bruno
|