Changeset 5001:af12e5845239 in roaraudio


Ignore:
Timestamp:
05/24/11 00:09:13 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_mm_sizeof()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/memmgr.h

    r4974 r5001  
    4747#ifdef ROAR_USE_MEMMGR 
    4848// those functions are currently not implemeted: 
     49 
     50ssize_t roar_mm_sizeof(void * buf); 
     51 
    4952void * roar_mm_calloc(size_t nmemb, size_t size); 
    5053void * roar_mm_malloc(size_t size); 
     
    5861 
    5962#else 
     63#define roar_mm_sizeof(ptr)         ((ssize_t)-1) 
    6064#define roar_mm_calloc(nmemb, size) calloc((nmemb), (size)) 
    6165#define roar_mm_malloc(size)        malloc((size)) 
  • libroar/memmgr.c

    r4992 r5001  
    5050 
    5151#ifdef ROAR_USE_MEMMGR 
     52ssize_t roar_mm_sizeof(void * buf) { 
     53 if ( buf == NULL ) { 
     54  roar_err_set(ROAR_ERROR_FAULT); 
     55  return -1; 
     56 } 
     57 
     58 if ( buf == _libroar_null_buffer_check ) 
     59  return 0; 
     60 
     61 roar_err_set(ROAR_ERROR_NOTSUP); 
     62 return -1; 
     63} 
     64 
    5265void * roar_mm_calloc(size_t nmemb, size_t size) { 
    5366 void * ret; 
     
    123136 
    124137void * roar_mm_realloc(void *ptr, size_t size) { 
    125 #ifdef ROAR_HAVE_REALLOC 
    126  void * ret; 
     138 void * ret; 
     139#ifndef ROAR_HAVE_REALLOC 
     140 ssize_t len; 
    127141#endif 
    128142 
     
    145159 return ret; 
    146160#else 
    147  _err(ROAR_ERROR_NOTSUP); 
     161 len = roar_mm_sizeof(ptr); 
     162 if ( len == -1 ) 
     163  return NULL; 
     164 
     165 ret = roar_mm_malloc(size);  
     166 if ( ret == NULL ) 
     167  return NULL; 
     168 
     169 memcpy(ret, ptr, len > (ssize_t)size ? size : len); 
     170 
     171 return ret; 
    148172#endif 
    149173} 
Note: See TracChangeset for help on using the changeset viewer.