From 046857dfb88f05e6b310fe9ef07b9f2d3ac5922d Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Thu, 20 Feb 2014 22:42:56 +0100 Subject: Restructure project, make names more clear --- src/mystdlib.c | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/mystdlib.c (limited to 'src/mystdlib.c') diff --git a/src/mystdlib.c b/src/mystdlib.c deleted file mode 100644 index 17f123b..0000000 --- a/src/mystdlib.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include - -#include "mystdlib.h" - -MAP map_file( char *filename, int readonly ) -{ - struct stat fstatus; - MAP map = (MAP)malloc( sizeof( *map )); - - if( map ) - { - memset( map, 0, sizeof( *map )); - - if( ( map->fh = open( filename, readonly ? O_RDONLY : O_RDWR ) ) >= 0 ) - { - fstat( map->fh, &fstatus ); - if( ( map->addr = mmap( NULL, map->size = (size_t)fstatus.st_size, - PROT_READ | ( readonly ? 0 : PROT_WRITE), (readonly ? MAP_PRIVATE : MAP_SHARED), map->fh, 0) ) == MAP_FAILED ) - { - fprintf( stderr, "Mapping file '%s' failed\n", filename ); - close( map->fh ); free( map ); map = NULL; - } - } else { - fprintf( stderr, "Couldn't open file: '%s'\n", filename ); - free( map ); map = NULL; - } - } else { - fputs( "Couldn't allocate memory", stderr ); - } - - return map; -} - -void unmap_file ( MAP *pMap ) -{ - if( !pMap || !*pMap ) return; - munmap( (*pMap)->addr, (*pMap)->size); - close( (*pMap)->fh); - free( *pMap ); *pMap = NULL; -} - -int getfilesize( int fd, unsigned long *size) -{ - struct stat sb; - int ret; - if( fstat( fd, &sb )) return -1; - *size = sb.st_size; - return 0; -} -- cgit v1.2.3