Oracle Objects for OLE C++ Class Library
Release 9.2

Part Number A95896-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

Memory Ownership Conventions

One reason the C++ Class Library is easy to use is that it relieves developers of concerns about memory allocation. All memory used by the objects themselves is handled by their own methods. Users of the classes never have to allocate or free any pointers.

This design has two important consequences:

  1. For all strings passed into objects as method arguments, the objects takes care of managing the string. If the object needs the string beyond the execution time of the method it will make a copy of the string. The caller is never responsible for maintaining a copy of a passed-in string pointer.
  2. All strings returned by methods are owned by the object that returned it. Callers do not have to free them (should not free them!) because the object destructors will free them. When the object is destroyed or closed, the strings are freed. Strings returned by methods may be freed at other times. For instance when an OField returns a database value as a string it owns the string. Later, if you ask the same OField object for the database values as a string again (perhaps the dynaset has been navigated to another record) the old string will be freed. The OField only keeps the most current string. The valid lifetimes of returned strings is discussed in the documentation for each method that returns a string pointer.