Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbFreeResource

Release memory and system resources allocated by ctdbAllocResource().

DECLARATION

CTDBRET ctdbDECL ctdbFreeResource(CTHANDLE resource)

DESCRIPTION

Release system resources allocated by ctdbAllocResource().

  • resource is a resource handle allocated by ctdbAllocResource().

RETURN

ctdbFreeResource() returns CTDBRET_OK on success or CTDBRET_NOTRESOURCE error if the handle passed to ctdbFreeResource() was not allocated by ctdbAllocResource() or is invalid.

EXAMPLE

CTDBRET DisplayAllResources(CTHANDLE hTable)

{

CTDBRET eRet;

CTHANDLE hRes = ctdbAllocResource(hTable, 0, 0, NULL);

/* check if resource was allocated */

if (!hRes)

return ctdbGetError(hTable);

/* get the first resource */

/* note that no resource locks are acquired since we are not changing the resources */

if ((eRet = ctdbFirstResource(hRes, false)) != CTDBRET_OK)

{

ctdbFreeResource(hRes);

return eRet;

}

/* get the other resources */

do

{

/* display resource type, number and name */

printf("Resource type: %u, number: %u", ctdbGetResourceType(hRes), ctdbGetResourceNumber(hRes));

if (ctdbGetResourceName(hRes) != NULL)

printf(", name: \"\"\n", ctdbGetResourceName(hRes));

else

printf(", name: NULL"\n");

}

while ((eRet = ctdbNextResource(hRes, false)) != CTDBRET_OK);

ctdbFreeResource(hRes);

return eRet;

}

SEE ALSO

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

TOCIndex