- if ((of->of_ad = ad ? ad :
- calloc(1, sizeof(struct adouble))) == NULL) {
- syslog( LOG_ERR, "of_alloc: malloc: %m" );
- return NULL;
+ if (!ad) {
+ ad = malloc( sizeof( struct adouble ) );
+ if (!ad) {
+ syslog( LOG_ERR, "of_alloc: malloc: %m" );
+ return NULL;
+ }
+
+ /* initialize to zero. This is important to ensure that
+ ad_open really does reinitialize the structure. */
+ memset( ad, 0, sizeof( struct adouble ) );
+ } else {
+ /* Increase the refcount on this struct adouble. This is
+ decremented again in oforc_dealloc. */
+ ad->ad_refcount++;