2008 March 27th Thursday (三月 二十七日 木曜日)

The time is so scare as to complete our project on schedule.  So, the leader made a decision that we have to be on duty this Saturday.

  The updating DB function was added into our project.  I don't known why the Java group give up this function, so we have to implement it in C language.

  The duplication function from our customer is so complicated from devices to devices, and varing with versions and with environments.  So, the duplication
is related to many cases that we must considered.

new and delete operation

  The pseudocode of new operator (non-member style) is as follow.

void * operator new(size_t size)        // operator new may has other parameters.
{                                      

  if (size == 0) {                      // when request size is 0,
    size = 1;                           // convert 0 to 1.
  }                                    
  while (1) {
    allocate_memory();

    if (OK)
      return (the pointer to the memory);

    // failed, install the global new handler.
    new_handler globalhandler = set_new_handler(0);
    set_new_handler(globalhandler);

    if (globalhandler) (*globalhandler)();
    else throw std::bad_alloc();
  }
}

  The pseudocode of new operator (member style) is as follow.

void * base::operator new(size_t size)
{
  if (size != sizeof(base))
    return ::operator new(size);
  ...
}

  There also are the pseudocode of delete operator (non-member and member styles) are follow.

void operator delete(void *rawmemory)
{
  if (rawmemory == 0) return;
                                 //

  free_memory();

  return;
}

class base {
public:                            // operator delete
  static void * operator new(size_t size);
  static void operator delete(void *rawmemory, size_t size);
  ...
};

void base::operator delete(void *rawmemory, size_t size)
{
  if (rawmemory == 0) return;      // check null pointer

  if (size != sizeof(base)) {      // check size
    ::operator delete(rawmemory);  // invoke standard delete operator
    return;                       
  }

  free_memory();

  return;
}


2008 March 28th Friday (三月 二十八日 金曜日)

  Today we almost took one work day to look through the sources of this projects again. 

  We are going to experiment tomorrow.  However, on this noon, one device was crashed.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值