puzze 2014.07.12

来源:互联网 发布:网络软文推广 编辑:程序博客网 时间:2024/06/07 05:37

come from URL:http://bugs.mysql.com/bug.php?id=73272

I have some puzzle to understand the code, if someone knows it works, please gives me some  tips.



Description:Reduce two memset to one memset call for upd_create call.UNIV_INLINEupd_t*upd_create(/*=======*/        ulint           n,      /*!< in: number of fields */        mem_heap_t*     heap)   /*!< in: heap from which memory allocated */{        upd_t*  update;        update = (upd_t*) mem_heap_zalloc(heap, sizeof(upd_t));        update->n_fields = n;        update->fields = (upd_field_t*)                mem_heap_zalloc(heap, sizeof(upd_field_t) * n);        return(update);}there is no need to use two mem_heap_zalloc call.How to repeat:N/ASuggested fix:diff -rc --exclude='*.orig' --exclude=sql_yacc.cc --exclude=sql_yacc.h mysql-5.6.19/storage/innobase/include/row0upd.ic mysql-5.6.19-patched/storage/innobase/include/row0upd.ic*** mysql-5.6.19/storage/innobase/include/row0upd.ic2014-05-06 18:45:59.000000000 +0800--- mysql-5.6.19-patched/storage/innobase/include/row0upd.ic2014-07-11 14:01:53.000000000 +0800****************** 44,54 ****  {  upd_t*update;! update = (upd_t*) mem_heap_zalloc(heap, sizeof(upd_t));  update->n_fields = n;! update->fields = (upd_field_t*)! mem_heap_zalloc(heap, sizeof(upd_field_t) * n);  return(update);  }--- 44,56 ----  {  upd_t*update;! /* update = (upd_t*) mem_heap_zalloc(heap, sizeof(upd_t)); */! update = (upd_t*) mem_heap_zalloc(heap, sizeof(upd_t) + sizeof(upd_field_t) * n);  update->n_fields = n;! /* update->fields = (upd_field_t*)! mem_heap_zalloc(heap, sizeof(upd_field_t) * n); */! update->fields = (upd_field_t*)(&update[1]);  return(update);  }


0 0