예제 #1
0
/**
 * Allocates a SurfaceFit handle with a suitable default
 * capacity for the contained ArrList's.
 *
 * return
 *     SurfaceFit handle if sufficient memory was available,
 *     otherewise a handle to NULL.
 */
SurfaceFit_pa SurfaceFitAlloc()
{
    SurfaceFit_pa Result = NULL;

    Result = ALLOC_ITEM(SurfaceFit_s, "SurfaceFit structure");
    if (Result != NULL)
    {
        Result->SurfFitType = SurfFitType_NoFit;

        Result->Coord1   = ArrListAlloc(20, ArrListType_Double);
        Result->Coord2   = ArrListAlloc(20, ArrListType_Double);
        Result->Var      = ArrListAlloc(20, ArrListType_Double);
        Result->FitCoefs = ArrListAlloc(20, ArrListType_Double);

        /* If it failed to allocate any of the array lists, clean-up and exit. */
        if (Result->Coord1 == NULL || Result->Coord2 == NULL || Result->Var == NULL ||
            Result->FitCoefs == NULL)
        {
            if (Result->Coord1   != NULL) ArrListDealloc(&(Result->Coord1));
            if (Result->Coord2   != NULL) ArrListDealloc(&(Result->Coord2));
            if (Result->Var      != NULL) ArrListDealloc(&(Result->Var));
            if (Result->FitCoefs != NULL) ArrListDealloc(&(Result->FitCoefs));
            FREE_ITEM(Result, "SurfaceFit structure");
            Result = NULL;
        }
    }

    ENSURE(SurfaceFitIsValid(Result) || Result == NULL);
    return Result;
}
예제 #2
0
void FileStreamDealloc(FileStream_s **FileStream)
{
  REQUIRE(VALID_REF(FileStream));
  REQUIRE(VALID_REF(*FileStream) || *FileStream == NULL);

  if (*FileStream != NULL)
    {
      FREE_ITEM(*FileStream, "FileStream");
      *FileStream = NULL;
    }

  ENSURE(*FileStream == NULL);
}
예제 #3
0
파일: dataset.cpp 프로젝트: Brzous/WindFOAM
void ZoneSpecDealloc(ZoneSpec_s **ZoneSpec)
{
    REQUIRE(VALID_REF(ZoneSpec));
    REQUIRE(VALID_REF(*ZoneSpec) || *ZoneSpec == NULL);

    if (*ZoneSpec != NULL)
    {
        CleanoutZoneSpec(*ZoneSpec);

        FREE_ITEM(*ZoneSpec, "ZoneSpec structure");
        *ZoneSpec = NULL;
    }

    ENSURE(*ZoneSpec == NULL);
}
예제 #4
0
/**
 * Deallocates the SurfaceFit handle and set the handle to NULL.
 *
 * note
 *     Item destruction is the responsibility of the caller.
 *
 * param
 *     Reference to a SurfaceFit handle.
 */
void SurfaceFitDealloc(SurfaceFit_pa *SurfaceFit)
{
    REQUIRE(VALID_REF(SurfaceFit));
    REQUIRE(SurfaceFitIsValid(*SurfaceFit) || *SurfaceFit == NULL);

    if (*SurfaceFit != NULL)
    {
        /* release the ArrList's */
        if ((*SurfaceFit)->Coord1 != NULL) ArrListDealloc(&((*SurfaceFit)->Coord1));
        if ((*SurfaceFit)->Coord2 != NULL) ArrListDealloc(&((*SurfaceFit)->Coord2));
        if ((*SurfaceFit)->Var != NULL) ArrListDealloc(&((*SurfaceFit)->Var));

        /* release the list structure itself */
        FREE_ITEM(*SurfaceFit, "SurfaceFit structure");
        *SurfaceFit = NULL;
    }

    ENSURE(*SurfaceFit == NULL);
}
예제 #5
0
/**
 * Deallocates the BondAtomPairs handle and set the handle to NULL.
 *
 * note
 *     Item destruction is the responsibility of the caller.
 *
 * param
 *     Reference to a BondAtomPairs handle.
 */
void BondAtomPairsDealloc(BondAtomPairs_pa *BondAtomPairs)
{
    REQUIRE(VALID_REF(BondAtomPairs));
    REQUIRE(BondAtomPairsIsValid(*BondAtomPairs) || *BondAtomPairs == NULL);

    if (*BondAtomPairs != NULL)
    {
        /* release the ArrList's */
        if ((*BondAtomPairs)->Atom1 != NULL) ArrListDealloc(&((*BondAtomPairs)->Atom1));
        if ((*BondAtomPairs)->Atom2 != NULL) ArrListDealloc(&((*BondAtomPairs)->Atom2));

        /* Notify Tecplot of memory usage change */
        TecUtilMemoryChangeNotify(- (Int64_t)((*BondAtomPairs)->MemUsageReported));
        (*BondAtomPairs)->MemUsageReported = 0;

        /* release the list structure itself */
        FREE_ITEM(*BondAtomPairs, "BondAtomPairs structure");
        *BondAtomPairs = NULL;
    }

    ENSURE(*BondAtomPairs == NULL);
}
예제 #6
0
/**
 * Allocates a BondAtomPairs handle with a suitable default
 * capacity for the contained ArrList's.
 *
 * return
 *     BondAtomPairs handle if sufficient memory was available,
 *     otherewise a handle to NULL.
 */
BondAtomPairs_pa BondAtomPairsAlloc()
{
    BondAtomPairs_pa Result = NULL;

    Result = ALLOC_ITEM(BondAtomPairs_s, "BondAtomPairs structure");
    if (Result != NULL)
    {
        Result->MemUsageReported = 0;
        Result->Atom1   = ArrListAlloc(60, ArrListType_Long);
        Result->Atom2   = ArrListAlloc(60, ArrListType_Long);

        /* If it failed to allocate any of the array lists, clean-up and exit. */
        if (Result->Atom1 == NULL || Result->Atom2 == NULL)
        {
            if (Result->Atom1 != NULL) ArrListDealloc(&(Result->Atom1));
            if (Result->Atom2 != NULL) ArrListDealloc(&(Result->Atom1));
            FREE_ITEM(Result, "BondAtomPairs structure");
            Result = NULL;
        }
    }

    ENSURE(BondAtomPairsIsValid(Result) || Result == NULL);
    return Result;
}