STRUCT__HEADER__SET	* CreateHeaderSet(STRUCT__HEADER__SET * parent, char * name, char * value)
#endif
{
	STRUCT__HEADER__SET	* headerSet = new STRUCT__HEADER__SET;

	headerSet->structType = STRUCT_TYPE_HEADER_SET;
	headerSet->name = __copy__(name);
	headerSet->value = __copy__(value);

	//headerSet->hTreeItem = 0;
#ifdef	_UNICODE
	headerSet->nameBuffer = new wchar_t[512];
#else
	headerSet->nameBuffer = new char[512];
#endif

	if	(parent) {
		STRUCT__HEADER__SET	** ppHeaderSet = &parent->child;
		while  ((*ppHeaderSet)) {
			ppHeaderSet = &(*ppHeaderSet)->next;
		}
		(*ppHeaderSet) = headerSet;
	}

	headerSet->child = 0;
	headerSet->next = 0;

	return	headerSet;
}
Beispiel #2
0
	inline
	int queue<T>::__reallocate__(uint64_t n)
	{
		// first allocate
		if(!_data){
			_data = new T[InitAlloc];
			if( !_data ){
				return -1;
			}
			_nalloc = InitAlloc;
			return 0;
		}

		{ // ---> reallocate
			T* stack;
			uint64_t nalloc;

			// compute allocate size
			for(nalloc = _nalloc << 1; nalloc < n; nalloc <<= 1);

			// allocate for stack and copy
			if( !(stack = new T[nalloc]) ){
				return -1;
			}
			__copy__(stack, _data, _n);
			// deallocate former memory
			__deallocate__();

			// swap
			_data = stack;
			_nalloc = nalloc;
		} // <--- reallocate
		return 0;
	}
Beispiel #3
0
	inline
	int queue<T>::copy(const T* src, const uint64_t n)
	{
		gnd_assert(!src, -1, "invalid arugment");
		gnd_error(n == 0, 0, "ineffectual argument");

		// reallocate
		while(_nalloc < _n + n)	__reallocate__(_n + n);

		__copy__(_data, src, n);
		_n = n;
		return 0;
	}
Beispiel #4
0
	inline
	int queue<T>::move(const uint64_t i, T* dest, const uint64_t n)
	{
		gnd_assert(i + n >= _n, -1, "out of buffer");
		gnd_error(n == 0, 0, "ineffectual argument");

		// copy
		if(dest) __copy__(dest, _data + i, n);
		// move
		if(i + n != _n)	__move__(_data + i, _data + i + n, (_n - i - n));
		_n -= n;

		return 0;
	}
Beispiel #5
0
	inline
	int queue<T>::insert(const uint64_t i, const T* src, const uint64_t n)
	{
		gnd_assert(!src, -1, "invalid argument");
		gnd_assert(i > _n, -1, "out of buffer");
		gnd_error(n == 0, 0, "ineffectual argument");

		// reallocate
		while(_nalloc < _n + n)	__reallocate__(_n + n);

		// move
		if(i != _n)	__move__(_data + i + n, _data + i, (_n - i));
		// copy
		__copy__(_data + i, src, n);
		_n += n;

		return (int)i;
	}