Product Documentation

c-treeDB API API for C

Previous Topic

Next Topic

ctdbGetResourceData

Return a pointer to the resource data.

DECLARATION

pVOID ctdbDECL ctdbGetResourceData(CTHANDLE resource);

DESCRIPTION

Returns a pointer to the resource data. Call this function to retrieve the resource data pointer after a resource is read by one of ctdbFirstResource(), ctdbNextResource(), ctdbFindResource() or ctdbFindResourceByName().

  • resource is a handle returned by ctdbAllocResource().

RETURN

Return a pointer to resource data

EXAMPLE

CTDBRET ReadMyResource(CTHANDLE Handle, ULONG type, ULONG number, ppVOID data, pVRLEN size)

{

CTDBRET eRet;

CTHANDLE hRes = ctdbAllocResource(Handle, type, number, NULL);

/* check the resource handle allocation */

if (hRes == NULL)

{

eRet = ctdbGetError(Handle);

goto Exit;

}

/* get the resource */

if ((eRet = ctdbFindResource(hRes, type, number, NO)) != CTDBRET_OK)

goto Exit;

/* allocate a buffer large enough for the resource data */

*size = ctdbGetResourceDataLength(hRes);

if (*size > 0)

{

*data = (pVOID)malloc(*size);

if (*data == NULL)

{

eRet = CTDBRET_NOMEMORY;

goto Exit;

}

memcpy(*data, ctdbGetResourceData(hRes), *size);

}

Exit:

if (hRes)

ctdbFreeResource(hRes);

return eRet;

}

SEE ALSO

ctdbAllocResource(), ctdbFreeResource(), ctdbAddResource(), ctdbDeleteResource(), ctdbFirstResource(), ctdbNextResource(), ctdbFindResource(), ctdbFindResourceByName(), ctdbGetResourceType(), ctdbSetResourceType(), ctdbGetResourceNumber(), ctdbSetResourceNumber(), ctdbGetResourceName(), ctdbSetResourceName(), ctdbGetResourceDataLength(), ctdbGetResourceData(), ctdbSetResourceData(), ctdbIsResourceLocked(), ctdbUnlockResource()

TOCIndex