From: Sam S. <sd...@gn...> - 2005-01-26 17:10:16
|
> * Bruno Haible <oe...@py...t> [2005-01-25 20:28:06 +0100]: > > Sam wrote: >> > For the implementation of udigits_to_I: >> > Note that you cannot always interpret an array of type uint8[] as an >> > array of type uintD[]: The number of elements may not be a multiple >> > of sizeof(uintD)/sizeof(uint8) (what do you want to do with the last few >> > bytes in that case?), >> >> zero them out? (hmm, this implies little-endian). >> >> > and the alignment of the memory may not be a multiple of >> > alignof(uintD). >> >> crash? :-( > > Yes, likely. - But before talking about the implementation of an > unclear function, can you clarify what the function _should_ do? What > does the berkeley-db module expect from it? this is a platform-independent integer <--> bit sequence conversion. this should be the _inverse_ of fill_dbt() in bdb.c: } else if (bignump(obj)) { int need = sizeof(uintD)*Bignum_length(obj); key->ulen = key->size = MAX(re_len,need); key->data = my_malloc(key->size); begin_system_call(); memset(key->data,0,key->size); memcpy((char*)key->data + key->size - need,TheBignum(obj)->data,need); end_system_call(); return DBT_INTEGER; } else ... -- Sam Steingold (http://www.podval.org/~sds) running w2k <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.honestreporting.com> The world is coming to an end. Please log off. |