os/ossrv/ofdbus/dbus/tsrc/testapps/exes1/src/dbus_Maloc.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ofdbus/dbus/tsrc/testapps/exes1/src/dbus_Maloc.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +/*
     1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#include<stdio.h> 
    1.23 +#include <dbus/dbus.h>
    1.24 +#include <stdlib.h>
    1.25 +#include <string.h>
    1.26 +
    1.27 +#define LOG_FILE "c:\\logs\\Dbus_Maloc1_log1.txt"
    1.28 +#include "std_log_result.h"
    1.29 +#define LOG_FILENAME_LINE __FILE__, __LINE__
    1.30 +
    1.31 +void create_xml(int result)
    1.32 +{
    1.33 +	if(result)
    1.34 +		assert_failed = 1;
    1.35 +	
    1.36 +	testResultXml("Dbus_Maloc");
    1.37 +	close_log_file();
    1.38 +}
    1.39 +
    1.40 +int main()
    1.41 +{
    1.42 +   int *Mem_res;
    1.43 +	 int *rel_res;
    1.44 +   
    1.45 +	Mem_res = (int*)dbus_malloc(sizeof(int));
    1.46 +	 
    1.47 +	if(Mem_res== NULL)
    1.48 +		{
    1.49 +		std_log(LOG_FILENAME_LINE, "Malloc unsuccessful");
    1.50 +		std_log(LOG_FILENAME_LINE, "FAIL");
    1.51 +		create_xml(1);
    1.52 +		return 1;
    1.53 +		}
    1.54 +	else
    1.55 +		{
    1.56 +			std_log(LOG_FILENAME_LINE, "malloc successful");
    1.57 +				
    1.58 +			rel_res = (int*)dbus_realloc(Mem_res,10);
    1.59 +			if(rel_res == NULL)
    1.60 +				{
    1.61 +					std_log(LOG_FILENAME_LINE, "realloc is unsuccessful");
    1.62 +					std_log(LOG_FILENAME_LINE, "FAIL");
    1.63 +					dbus_free(Mem_res);
    1.64 +					create_xml(1);
    1.65 +					return 1;
    1.66 +				}
    1.67 +				else
    1.68 +					{
    1.69 +						std_log(LOG_FILENAME_LINE, "realloc is successful");
    1.70 +					std_log(LOG_FILENAME_LINE, "Success");
    1.71 +					create_xml(0);
    1.72 +					return 0;  
    1.73 +					}
    1.74 +		} 
    1.75 +		dbus_free(rel_res);
    1.76 +}