Ejemplo n.º 1
0
//////////
//
// Free the indicated font resource
//
//////
	void iFont_delete(SFont** fontRoot, bool tlDeleteSelf)
	{
		SFont* font;


		if (fontRoot && *fontRoot)
		{
			// Grab our pointer
			font = *fontRoot;


			//////////
			// Free components
			//////
				DeleteObject((HGDIOBJ)font->hfont);
				DeleteDC(font->hdc);
				iDatum_delete(&font->name, false);


			//////////
			// Free self
			//////
				if (tlDeleteSelf && ((uptr)font < gFonts->_data || (uptr)font > (gFonts->_data + gFonts->populatedLength)))
				{
					// Delete the memory block
					free(font);
					*fontRoot = NULL;

				} else {
					// Just mark it unused
					font->isUsed = false;
				}
		}
	}
Ejemplo n.º 2
0
void iDatum_delete(SDatum** datum)
{
    if (datum)
    {
        // Delete and reset our pointer
        iDatum_delete(*datum, true);
        *datum = NULL;
    }
}
Ejemplo n.º 3
0
SProperty* iProperty_allocateAs_character(cu8* tcName, s32 tnNameLength, cu8* tcValue, s32 tnValueLength)
{
    SDatum*		name;
    SVariable*	value;
    SProperty*	p;


    // Make sure our environment is sane
    p = NULL;
    if (tcName)
    {
        // Allocate a name
        name = iDatum_allocate(tcName, tnNameLength);
        if (name)
        {
            // Allocate the value
            value = iVariable_createAndPopulate_byText(iiVariable_getType_character(), tcValue, tnValueLength, false);
            if (value)
            {
                // Allocate a property
                p = iiProperty_allocate(name, value);
                if (p)
                {
                    // Both were allocated
                    p->name_allocated	= true;
                    p->value_allocated	= true;

                } else {
                    // Failure on creating the property
                    iDatum_delete(&name);
                    iVariable_delete(&value);
                }

            } else {
                // Failure on creating the variable
                iDatum_delete(&name);
            }
        }
    }

    // Indicate our property
    return(p);
}
Ejemplo n.º 4
0
//////////
//
// Free the edit chain
//
//////
	void iSEMLine_free(SThisCode* thisCode, SLine** root, bool tlDeleteSelf)
	{
		SLine*		line;
		SLine*		lineNext;


		// Make sure our environment is sane
		if (root && *root)
		{
			//////////
			// Repeat throughout the entire chain
			//////
				line = *root;
				while (line)
				{
					//////////
					// Note next item in chain
					//////
						lineNext = (SLine*)line->ll.next;


					//////////
					// Delete any extra information associated with this chain entry
					//////
						iExtraInfo_removeAll(thisCode, NULL, line, &line->extra_info, true);


					//////////
					// Delete this item's components and source code references
					//////
						iComps_deleteAll_byLine(thisCode, line);
						iDatum_delete(line->sourceCode, true);


					//////////
					// Free self
					//////
						if (tlDeleteSelf)
							free(line);


					//////////
					// Move to next item in the chain
					//////
						line = lineNext;
				}


			//////////
			// Free self
			//////
				if (tlDeleteSelf)
					*root = NULL;	// It would've been freed above, so we just update the pointer
		}
	}
Ejemplo n.º 5
0
SProperty* iProperty_delete(SProperty* p, bool tlDeleteSelf)
{
    // Make sure our environment is sane
    if (p)
    {
        // Clean up the name and value
        if (p->name  && p->name_allocated)		iDatum_delete(&p->name);
        if (p->value && p->value_allocated)		iVariable_delete(&p->value);

        // Delete self
        if (tlDeleteSelf)
            free(p);
    }

    // Pass-thru
    return(p);
}
Ejemplo n.º 6
0
//////////
//
// Called to free the extra info associated with this entry
//
//////
	void iExtraInfo_removeAll(SEM* sem, SLine* line, SExtraInfo** root, bool tlDeleteSelf)
	{
		SExtraInfo*		ei;
		SExtraInfo*		eiNext;


		// Make sure our environment is sane
		if (root && *root)
		{
// TODO:  COMPLETELY UNTESTED.  BREAKPOINT AND EXAMINE.
debug_break;
			// Iterate through all entries in the chain
			ei = *root;
			while (ei)
			{
				// Note the next entry
				eiNext = ei->ll.nextExtraInfo;


				//////////
				// Call any freeInternal() functions to the data contained within and manually delete the extra info block
				//////
					if (ei->_freeInternal!= 0)
						ei->freeInternal(NULL, line, ei);

					// Now, manually free the actual info block itself
					iDatum_delete(&ei->info, false);


				// Free self if need be
				if (tlDeleteSelf)
					free(ei);

				// Move to next entry
				ei = eiNext;
			}

			// Reset the root pointer
			*root = NULL;
		}
	}