_resize.h 1.2 KB
/**
 * \file
 *
 * \author	Georg Hopp
 *
 * \copyright
 * Copyright © 2014 Georg Hopp
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef __TR_SET_RESIZE_H__
#define __TR_SET_RESIZE_H__

#include "trbase.h"
#include "tr/set.h"

inline
void
_TR_setResize(TR_Set this)
{
	void   ** new      = TR_calloc(this->size+1, sizeof(void*));
	size_t    new_size = TR_getUsableSize(new) / sizeof(void *);

#define GROWTH	(new_size - this->size)

	memcpy(new, this->data, this->size * sizeof(void*));
	TR_MEM_FREE(this->data);
	this->size  = new_size;
	this->data  = new;
}

#endif // __TR_SET_RESIZE_H__

// vim: set ts=4 sw=4: