示例#1
0
  bool Plugin::unload()
  {
    flushPool();

    unloadFactories();
    unloadMetadata();
    
    return DynamicLibrary::unload();
  }
示例#2
0
void PoolMemoryAllocator::flushPool()
{
#ifndef OGDF_MEMORY_POOL_NTS
	for(__uint16 nBytes = 1; nBytes < eTableSize; ++nBytes) {
#ifdef OGDF_NO_COMPILER_TLS
	MemElemPtr p = ((MemElemPtr*)pthread_getspecific(s_tpKey))[nBytes];
#else
	MemElemPtr p = s_tp[nBytes];
#endif
		if(p != 0)
			flushPool(nBytes);
	}
#endif
}
示例#3
0
void displayModeBar(int cursorArea,Area window,struct modeBar modeBar){
	int i;
	int totalLength = modeBar.nModes * UI_MODE_LABEL_WIDTH;
	char *next = "%s%s";
	char *format = "%s%-*s";
	char *formatSelected = "[%s]";
	int col = window.top;
	int row = window.left;
	char *output = '\0';
	for(i = 0; i < modeBar.nModes;i++) {
		char *input = modeBar.modes[i].text;

		char * color = getColor(classicModeBar.subject);
		if(isMode(cursorArea,modeBar.modes[i])) {
			color = getColor(classicModeBar.body);
			input = saveFormatted(formatSelected,input);
		}
		input = saveFormatted(format,color,UI_MODE_LABEL_WIDTH,input);
		if(output) {
			output = saveFormatted(next,output,input);
		} else {
			output = saveFormatted(input);
		}
		//message(output);
	}
	/*for(i = 0; i < modeBar.nModes;i++) {
		totalLength += strlen(modeBar.modes[i].text);
		totalLength += 2;
	}*/
	col = (window.right - totalLength) / 2;
	if(col < window.left) {
		col = window.left;
	}
	row = verticalMargin(modeBar.verticalMargin,window);

	xt_par2(XT_SET_ROW_COL_POS,row,col);
	printf(output);
	flushPool();

}
示例#4
0
    void* malloc(size_t bytes) {
        lock();
        ++totalMallocs;

        if (bytes <= tinyBufferSize) {

            void* ptr = tinyMalloc(bytes);

            if (ptr) {
                ++mallocsFromTinyPool;
                unlock();
                return ptr;
            }

        } 
        
        // Failure to allocate a tiny buffer is allowed to flow
        // through to a small buffer
        if (bytes <= smallBufferSize) {
            
            void* ptr = malloc(smallPool, smallPoolSize, bytes);

            if (ptr) {
                ++mallocsFromSmallPool;
                unlock();
                return ptr;
            }

        } else  if (bytes <= medBufferSize) {
            // Note that a small allocation failure does *not* fall
            // through into a medium allocation because that would
            // waste the medium buffer's resources.

            void* ptr = malloc(medPool, medPoolSize, bytes);

            if (ptr) {
                ++mallocsFromMedPool;
                unlock();
                return ptr;
            }
        }

        bytesAllocated += 4 + (int) bytes;
        unlock();

        // Heap allocate

        // Allocate 4 extra bytes for our size header (unfortunate,
        // since malloc already added its own header).
        void* ptr = ::malloc(bytes + 4);

        if (ptr == NULL) {
            // Flush memory pools to try and recover space
            flushPool(smallPool, smallPoolSize);
            flushPool(medPool, medPoolSize);
            ptr = ::malloc(bytes + 4);
        }


        if (ptr == NULL) {
            if ((System::outOfMemoryCallback != NULL) &&
                (System::outOfMemoryCallback(bytes + 4, true) == true)) {
                // Re-attempt the malloc
                ptr = ::malloc(bytes + 4);
            }
        }

        if (ptr == NULL) {
            if (System::outOfMemoryCallback != NULL) {
                // Notify the application
                System::outOfMemoryCallback(bytes + 4, false);
            }
            return NULL;
        }

        *(uint32*)ptr = (uint32)bytes;

        return (uint8*)ptr + 4;
    }