00001 00009 /* 00010 * Copyright © 2008 Red Hat, Inc. All rights reserved. 00011 * Copyright © 2008 Ding-Yi Chen <dchen at redhat dot com> 00012 * 00013 * This file is part of the libUnihan Project. 00014 * 00015 * This library is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU Lesser General Public 00017 * License as published by the Free Software Foundation; either 00018 * version 2 of the License, or (at your option) any later version. 00019 * 00020 * This library is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU Lesser General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU Lesser General Public 00026 * License along with this program; if not, write to the 00027 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00028 * Boston, MA 02111-1307 USA 00029 */ 00030 00031 #ifndef ALLOCATE_UTILS_H_ 00032 #define ALLOCATE_UTILS_H_ 00033 #include <stdlib.h> 00034 #include <glib.h> 00035 00049 void **array2D_new(size_t row_size, size_t col_size, size_t element_size, size_t pointer_size); 00050 00056 void array2D_free(void **arrayPtr); 00057 00058 00065 #define NEW_INSTANCE(type) g_new(type,1) 00066 00067 00075 #define NEW_ARRAY_INSTANCE(element_count,element_type) g_new(element_type,element_count) 00076 00085 #define NEW_ARRAY2D_INSTANCE(row_size,col_size,element_type) (element_type**) array2D_new(row_size,col_size,sizeof(element_type),sizeof(element_type*)); 00086 00087 #endif /*ALLOCATE_UTILS_H_*/