os/ossrv/ofdbus/dbus/tsrc/testapps/exes1/src/dbus_Maloc.c
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #include<stdio.h> 
    20 #include <dbus/dbus.h>
    21 #include <stdlib.h>
    22 #include <string.h>
    23 
    24 #define LOG_FILE "c:\\logs\\Dbus_Maloc1_log1.txt"
    25 #include "std_log_result.h"
    26 #define LOG_FILENAME_LINE __FILE__, __LINE__
    27 
    28 void create_xml(int result)
    29 {
    30 	if(result)
    31 		assert_failed = 1;
    32 	
    33 	testResultXml("Dbus_Maloc");
    34 	close_log_file();
    35 }
    36 
    37 int main()
    38 {
    39    int *Mem_res;
    40 	 int *rel_res;
    41    
    42 	Mem_res = (int*)dbus_malloc(sizeof(int));
    43 	 
    44 	if(Mem_res== NULL)
    45 		{
    46 		std_log(LOG_FILENAME_LINE, "Malloc unsuccessful");
    47 		std_log(LOG_FILENAME_LINE, "FAIL");
    48 		create_xml(1);
    49 		return 1;
    50 		}
    51 	else
    52 		{
    53 			std_log(LOG_FILENAME_LINE, "malloc successful");
    54 				
    55 			rel_res = (int*)dbus_realloc(Mem_res,10);
    56 			if(rel_res == NULL)
    57 				{
    58 					std_log(LOG_FILENAME_LINE, "realloc is unsuccessful");
    59 					std_log(LOG_FILENAME_LINE, "FAIL");
    60 					dbus_free(Mem_res);
    61 					create_xml(1);
    62 					return 1;
    63 				}
    64 				else
    65 					{
    66 						std_log(LOG_FILENAME_LINE, "realloc is successful");
    67 					std_log(LOG_FILENAME_LINE, "Success");
    68 					create_xml(0);
    69 					return 0;  
    70 					}
    71 		} 
    72 		dbus_free(rel_res);
    73 }