Index: ossp-pkg/uuid/ChangeLog RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v rcsdiff -q -kk '-r1.132' '-r1.133' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/ChangeLog,v' 2>/dev/null --- ChangeLog 2006/08/02 13:11:09 1.132 +++ ChangeLog 2006/10/06 08:32:40 1.133 @@ -11,7 +11,28 @@ This is a list of all changes to OSSP uuid. For a more brief summary please have a look at the NEWS file. - Changes between 1.5.1 and 1.5.2 (31-Jul-2006 to xx-Aug-2006) + Changes between 1.5.1 and 1.6.0 (31-Jul-2006 to 05-Oct-2006) + + o Change type of "data_ptr" argument in uuid_export() API signature + from "void **" to "void *" as there is unfortunately no + "generic pointer to pointer type" in ISO C (see also + http://c-faq.com/ptrs/genericpp.html) and "void **" is just a + "pointer to a 'void *'". + + The "void **" especially had the nasty side-effect that it breaks + strict pointer aliasing rules of ISO C and hence would require + fiddling with temporary variables on all uuid_export() calls if + one would be 100% correct and avoid aliasing related compiler + warnings. Instead, as uuid_export() internally has to cast the + "data_ptr" to the particular expected type anyway, it is better + to have "data_ptr" just be a really generic "void *" in the API + signature. + + Keep in mind that although this is an API change, it doesn't cause + any incompatibilities as the function still expects the same + "pointer to a pointer of a particular type". This expected pointer + is just now passed the more correct although less intuitive way. + [Hrvoje Niksic , Ralf S. Engelschall] o Optional DMALLOC based memory debugging support. [Ralf S. Engelschall] Index: ossp-pkg/uuid/THANKS RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/THANKS,v rcsdiff -q -kk '-r1.11' '-r1.12' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/THANKS,v' 2>/dev/null --- THANKS 2006/07/31 12:44:03 1.11 +++ THANKS 2006/10/06 08:32:40 1.12 @@ -18,6 +18,7 @@ o Fuyuki o Thomas Lotterer o Roman Neuhauser + o Hrvoje Niksic o Piotr Roszatycki o Michael Schloh o Guerry Semones Index: ossp-pkg/uuid/uuid.c RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v rcsdiff -q -kk '-r1.62' '-r1.63' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.c,v' 2>/dev/null --- uuid.c 2006/08/02 13:11:09 1.62 +++ uuid.c 2006/10/06 08:32:40 1.63 @@ -328,20 +328,24 @@ /* INTERNAL: pack UUID object into binary representation (allows in-place operation for internal efficiency!) */ -static uuid_rc_t uuid_export_bin(const uuid_t *uuid, void **data_ptr, size_t *data_len) +static uuid_rc_t uuid_export_bin(const uuid_t *uuid, void *_data_ptr, size_t *data_len) { + uuid_uint8_t **data_ptr; uuid_uint8_t *out; uuid_uint32_t tmp32; uuid_uint16_t tmp16; unsigned int i; + /* cast generic data pointer to particular pointer to pointer type */ + data_ptr = (uuid_uint8_t **)_data_ptr; + /* sanity check argument(s) */ if (uuid == NULL || data_ptr == NULL) return UUID_RC_ARG; /* optionally allocate octet data buffer */ if (*data_ptr == NULL) { - if ((*data_ptr = malloc(sizeof(uuid_t))) == NULL) + if ((*data_ptr = (uuid_uint8_t *)malloc(sizeof(uuid_t))) == NULL) return UUID_RC_MEM; if (data_len != NULL) *data_len = UUID_LEN_BIN; @@ -355,7 +359,7 @@ } /* treat output data buffer as octet stream */ - out = (uuid_uint8_t *)(*data_ptr); + out = *data_ptr; /* pack "time_low" field */ tmp32 = uuid->obj.time_low; @@ -492,10 +496,14 @@ } /* INTERNAL: export UUID object to string representation */ -static uuid_rc_t uuid_export_str(const uuid_t *uuid, void **data_ptr, size_t *data_len) +static uuid_rc_t uuid_export_str(const uuid_t *uuid, void *_data_ptr, size_t *data_len) { + char **data_ptr; char *data_buf; + /* cast generic data pointer to particular pointer to pointer type */ + data_ptr = (char **)_data_ptr; + /* sanity check argument(s) */ if (uuid == NULL || data_ptr == NULL) return UUID_RC_ARG; @@ -543,8 +551,9 @@ } /* INTERNAL: export UUID object to single integer value representation */ -static uuid_rc_t uuid_export_siv(const uuid_t *uuid, void **data_ptr, size_t *data_len) +static uuid_rc_t uuid_export_siv(const uuid_t *uuid, void *_data_ptr, size_t *data_len) { + char **data_ptr; char *data_buf; void *tmp_ptr; size_t tmp_len; @@ -553,6 +562,9 @@ uuid_rc_t rc; int i; + /* cast generic data pointer to particular pointer to pointer type */ + data_ptr = (char **)_data_ptr; + /* sanity check argument(s) */ if (uuid == NULL || data_ptr == NULL) return UUID_RC_ARG; @@ -621,8 +633,9 @@ }; /* INTERNAL: dump UUID object as descriptive text */ -static uuid_rc_t uuid_export_txt(const uuid_t *uuid, void **data_ptr, size_t *data_len) +static uuid_rc_t uuid_export_txt(const uuid_t *uuid, void *_data_ptr, size_t *data_len) { + char **data_ptr; uuid_rc_t rc; char **out; char *out_ptr; @@ -648,6 +661,9 @@ struct tm *tm; int i; + /* cast generic data pointer to particular pointer to pointer type */ + data_ptr = (char **)_data_ptr; + /* sanity check argument(s) */ if (uuid == NULL || data_ptr == NULL) return UUID_RC_ARG; @@ -820,7 +836,7 @@ } /* UUID exporting */ -uuid_rc_t uuid_export(const uuid_t *uuid, uuid_fmt_t fmt, void **data_ptr, size_t *data_len) +uuid_rc_t uuid_export(const uuid_t *uuid, uuid_fmt_t fmt, void *data_ptr, size_t *data_len) { uuid_rc_t rc; Index: ossp-pkg/uuid/uuid.h.in RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.h.in,v rcsdiff -q -kk '-r1.12' '-r1.13' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.h.in,v' 2>/dev/null --- uuid.h.in 2006/05/11 09:37:28 1.12 +++ uuid.h.in 2006/10/06 08:32:40 1.13 @@ -108,7 +108,7 @@ /* UUID import/export */ extern uuid_rc_t uuid_import ( uuid_t *_uuid, uuid_fmt_t _fmt, const void *_data_ptr, size_t _data_len); -extern uuid_rc_t uuid_export (const uuid_t *_uuid, uuid_fmt_t _fmt, void **_data_ptr, size_t *_data_len); +extern uuid_rc_t uuid_export (const uuid_t *_uuid, uuid_fmt_t _fmt, void *_data_ptr, size_t *_data_len); /* library utilities */ extern char *uuid_error (uuid_rc_t _rc); Index: ossp-pkg/uuid/uuid.pod RCS File: /v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.pod,v rcsdiff -q -kk '-r1.40' '-r1.41' -u '/v/ossp/cvs/ossp-pkg/uuid/Attic/uuid.pod,v' 2>/dev/null --- uuid.pod 2006/08/01 19:35:07 1.40 +++ uuid.pod 2006/10/06 08:32:40 1.41 @@ -328,21 +328,34 @@ minimum expected length in I depends on it. Valid values for I are B, B and B. -=item uuid_rc_t B(const uuid_t *I, uuid_fmt_t I, void **I, size_t *I); +=item uuid_rc_t B(const uuid_t *I, uuid_fmt_t I, void *I, size_t *I); -Exports a UUID I into an external representation of format I. -The data is written to the buffer at C<*>I which has to -be room for at least C<*>I bytes. If C<*>I is -C, I is ignored as input and a new buffer is allocated -and returned in C<*>I (the caller has to free(3) it later -on). If I is not C, the number of available bytes at -C<*>I has to be provided in C<*>I and the number of -actually written bytes are returned in C<*>I again. - -The format of the external representation is specified by I and the -minimum required length in C<*>I depends on it. Valid values -for I are B, B, B and -B. +Exports a UUID I into an external representation of format +I. Valid values for I are B, B, +B and B. + +The data is written to the buffer whose location is obtained +by dereferencing I after a "cast" to the appropriate +pointer-to-pointer type. Hence the generic pointer argument I +is expected to be a pointer to a "pointer of a particular type", i.e., +it has to be of type "C" for B and +"C" for B, B and B. + +The buffer has to be room for at least C<*>I bytes. If the +value of the pointer after "casting" and dereferencing I +is C, I is ignored as input and a new buffer is +allocated and returned in the pointer after "casting" and dereferencing +I (the caller has to free(3) it later on). + +If I is not C, the number of available bytes in the +buffer has to be provided in C<*>I and the number of actually +written bytes are returned in C<*>I again. The minimum +required buffer length depends on the external representation as +specified by I and is at least B for B, +B for B and B for +B. For B a buffer of unspecified length is +required and hence it is recommended to allow B to allocate +the buffer as necessary. =item uuid_rc_t B(uuid_t *I, const char *I); @@ -418,7 +431,7 @@ uuid_create(&uuid); uuid_make(uuid, UUID_MAKE_V1); str = NULL; - uuid_export(uuid, UUID_FMT_STR, (void **)&str, NULL); + uuid_export(uuid, UUID_FMT_STR, &str, NULL); uuid_destroy(uuid); return str; } @@ -435,7 +448,7 @@ uuid_load(uuid_ns, "ns:URL"); uuid_make(uuid, UUID_MAKE_V3, uuid_ns, url); str = NULL; - uuid_export(uuid, UUID_FMT_STR, (void **)&str, NULL); + uuid_export(uuid, UUID_FMT_STR, &str, NULL); uuid_destroy(uuid_ns); uuid_destroy(uuid); return str;