Previous Topic

Next Topic

ReleaseData

Release fixed-length data record for reuse.

Short Name

RETREC()

Type

Low-level data file function

Declaration

COUNT ReleaseData(COUNT datno, LONG recbyt)

Description

ReleaseData() adds record position recbyt to the chain of deleted records for fixed-length file datno. ReleaseData() should be called when a data record is no longer needed so that the space can be reused. Records returned by ReleaseData() are reused by NewData() before the data file is extended. ReleaseData() is automatically called by DeleteRecord().

Return

Value

Symbolic Constant

Explanation

0

NO_ERROR

Successful return operation.

29

ZREC_ERR

recbyt is zero.

30

LEOF_ERR

recbyt exceeds the logical end-of-file maintained in the data file header.

32

DDRN_ERR

Attempt to return recbyt twice in a row.

48

FMOD_ERR

datno is not assigned to a fixed-length data file.

57

DADV_ERR

Proper lock not found by the c-tree Server.

See c-tree Plus Error Codes for a complete listing of valid c-tree Plus error values.

Example

COUNT     keyno,datno;
LONG      recbyt;
pTEXT     target;

if (recbyt = GetKey(keyno,target))
    if (DeleteKey(keyno,target,recbyt) == NO_ERROR)
        if (ReleaseData(datno,recbyt) == NO_ERROR)
            printf("\nSUCCESS.");

Limitations

ReleaseData() writes an 0xff byte and a 4-byte data record position starting at the first byte of the returned data record. Therefore, even if you only write ASCII information into the data records, ReleaseData() will place binary information into the beginning of deleted records.

The recbyt parameter in this function is a 4-byte value capable of addressing at most 4 gigabytes. If your application supports HUGE files (greater than 4 gigabytes), you must use the ctSetHgh() and ctGetHgh() functions to set or get the high order 4 bytes of the file offset.

See also

ctSetHgh(), ctGetHgh(), DeleteRecord(), LockCtData(), NewData()