sl@0: // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: // We use the EPOC32 memory allocation which is already sl@0: // thread-safe, so we don't need the _malloc_r variants sl@0: sl@0: extern "C" { sl@0: sl@0: EXPORT_C void* malloc (size_t nbytes) sl@0: { sl@0: return User::Alloc(nbytes); sl@0: } sl@0: sl@0: EXPORT_C void* realloc (void *p, size_t nbytes) sl@0: { sl@0: return User::ReAlloc(p, nbytes); sl@0: } sl@0: sl@0: EXPORT_C void free (void *p) sl@0: { sl@0: User::Free(p); sl@0: } sl@0: sl@0: #ifdef EKA2 sl@0: EXPORT_C void* _placeholder_memmove (void* to, const void* from, size_t len) sl@0: #else sl@0: EXPORT_C void* memmove (void* to, const void* from, size_t len) sl@0: #endif sl@0: { sl@0: Mem::Copy(to, from, len); // E32 unaligned careful copy sl@0: return to; sl@0: } sl@0: sl@0: #ifdef EKA2 sl@0: EXPORT_C void* _placeholder_memset (void* to, int c, size_t len) sl@0: #else sl@0: EXPORT_C void* memset (void* to, int c, size_t len) sl@0: #endif sl@0: { sl@0: Mem::Fill(to,len,c); sl@0: return to; sl@0: } sl@0: sl@0: EXPORT_C void* calloc (size_t n, size_t size) sl@0: { sl@0: n *= size; sl@0: void *ret = User::Alloc(n); sl@0: if (ret == 0) sl@0: return 0; sl@0: Mem::FillZ(ret,n); sl@0: return ret; sl@0: } sl@0: sl@0: EXPORT_C size_t strlen (const char *str) sl@0: { sl@0: return User::StringLength((TUint8*)str); sl@0: } sl@0: sl@0: EXPORT_C size_t wcslen (const wchar_t *str) sl@0: { sl@0: return User::StringLength((TUint16*)str); sl@0: } sl@0: sl@0: EXPORT_C unsigned int sleep (unsigned int secs) sl@0: { sl@0: // we don't allow the possibility of being woken by signals sl@0: User::After(secs*1000000); sl@0: return 0; sl@0: } sl@0: sl@0: } // extern "C"