Errata for Advanced CORBA Programming with C++ (1st Printing)

Last updated: 28 January 2004


A number of people have submitted comments, constructive criticism, and feedback since the first printing. Our thanks go to everyone who helped us weed out bugs and make this a better book. All the people who contributed are listed in the acknowledgments to our readers.

Example Code

Use of assert Macro

The code examples in the book in many places use the assert macro as an extremely crude form of error handling. For example, on page 396:
assert(ICP_get(m_anum, "model", buf, sizeof(buf)) == 0);
We did this mainly to keep code examples short and to avoid distracting from the main message with lots of error-handling code. However, using assert in this way means that if you compile the code with NDEBUG defined, it will no longer work correctly because the assertion has a side effect that no longer occurs when the assertion is disabled.

Quite a few of the code examples in the book rely on assertions not being disabled. A number of people have pointed out to us that using assertions in this way is bad style, and we agree. For your own code, you should ensure that assertions do not have side effects.

Use of delete[] with ostrstream

A number of examples show code along the following lines:
ostrstream ostr;
ostr << "whatever..." << ends;
char * text_p = ostr.str();
// ...
delete[] text_p;
The str member function passes responsibility for deallocation of the string to the caller. However, the use of delete[] to deallocate that string is not portable, nor is use of delete (although either or both work fine in many implementations). Instead, explicit deallocation of the string requires a call to ::operator delete(text_p).

However, another option is to use freeze(0) to return responsibility for deallocation to the ostrstream, so memory for the string returned by str is deallocated when the ostrstream goes out of scope. Therefore, the above code fragment should read:

ostrstream ostr;
ostr << "whatever..." << ends;
char * text_p = ostr.str();
// ...

Chapter 2

Chapter 3

Chapter 4

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Chapter 14

Chapter 15

Chapter 16

Chapter 17

Chapter 18

Chapter 19

Chapter 20

Chapter 21

Appendix A

Back to:

Valid HTML 3.2!