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.

你可能感兴趣的:(2008 March 27th Thursday (三月 二十七日 木曜日))