sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. sl@0: * sl@0: * This library is free software; you can redistribute it and/or sl@0: * modify it under the terms of the GNU Lesser General Public sl@0: * License as published by the Free Software Foundation; either sl@0: * version 2 of the License, or (at your option) any later version. sl@0: * sl@0: * This library is distributed in the hope that it will be useful, sl@0: * but WITHOUT ANY WARRANTY; without even the implied warranty of sl@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU sl@0: * Lesser General Public License for more details. sl@0: * sl@0: * You should have received a copy of the GNU Lesser General Public sl@0: * License along with this library; if not, write to the sl@0: * Free Software Foundation, Inc., 59 Temple Place - Suite 330, sl@0: * Boston, MA 02111-1307, USA. sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: sl@0: #undef G_DISABLE_ASSERT sl@0: #undef G_LOG_DOMAIN sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef SYMBIAN sl@0: #include "mrt2_glib2_test.h" sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: void myLogHandler(const gchar* log_domain, GLogLevelFlags log_level, sl@0: const gchar* message, gpointer user_data) sl@0: { sl@0: FILE *fp; sl@0: fp = fopen("c:\\meminfo.txt","a"); sl@0: sl@0: if(fp) sl@0: { sl@0: fprintf(fp,message); sl@0: fprintf(fp,"\n"); sl@0: fclose(fp); sl@0: } sl@0: } sl@0: sl@0: void g_mem_is_system_malloc_test() sl@0: { sl@0: g_assert(g_mem_is_system_malloc()); sl@0: } sl@0: sl@0: void g_mem_chunk_reset_test() sl@0: { sl@0: gchar *name = "chunk"; sl@0: GMemChunk *mem_chunk = g_mem_chunk_new(name,2,10,G_ALLOC_AND_FREE); sl@0: guint16 *x = g_mem_chunk_alloc(mem_chunk); sl@0: *x = 50; sl@0: g_mem_chunk_reset(mem_chunk); sl@0: *x = 10; sl@0: } sl@0: sl@0: void g_mem_test() sl@0: { sl@0: GMemVTable temp_glib_mem_vtable = { sl@0: malloc, sl@0: realloc, sl@0: free, sl@0: calloc, sl@0: malloc, sl@0: realloc, sl@0: }; sl@0: sl@0: gchar *name = "chunk"; sl@0: GMemChunk *mem_chunk; sl@0: guint16 *x = NULL; sl@0: sl@0: FILE *fp; sl@0: sl@0: g_mem_set_vtable(&temp_glib_mem_vtable); sl@0: mem_chunk = g_mem_chunk_new(name,2,10,G_ALLOC_AND_FREE); sl@0: x = g_mem_chunk_alloc(mem_chunk); sl@0: g_assert(x != NULL); sl@0: } sl@0: sl@0: int sl@0: main (int argc, char *argv[]) sl@0: { sl@0: #ifdef SYMBIAN sl@0: sl@0: g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); sl@0: #endif /*SYMBIAN*/ sl@0: sl@0: g_mem_is_system_malloc_test(); sl@0: g_mem_chunk_reset_test(); sl@0: g_mem_test(); sl@0: sl@0: #ifdef SYMBIAN sl@0: testResultXml("mem_test"); sl@0: #endif /* EMULATOR */ sl@0: sl@0: return 0; sl@0: }