Adding menuetlibc back to its place in /programs/develop/libraries
This version of menuetlibc was taken from revision 4743, right before I made any changes git-svn-id: svn://kolibrios.org@4973 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
49
programs/develop/libraries/menuetlibc/linuxtools/mchmem.c
Normal file
49
programs/develop/libraries/menuetlibc/linuxtools/mchmem.c
Normal file
@@ -0,0 +1,49 @@
|
||||
#define OFF 20
|
||||
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
|
||||
int main(int argc,char * argv[])
|
||||
{
|
||||
FILE * f;
|
||||
char * buf;
|
||||
unsigned long sz,newsz;
|
||||
if(argc<3)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf("%s filename memsize_hex\n",argv[0]);
|
||||
printf("Example:\n\t%s test.app 100000\n",argv[0]);
|
||||
return -1;
|
||||
}
|
||||
sscanf(argv[2],"%x",&newsz);
|
||||
if(newsz<0x10000 || newsz>0x2000000) /* Min 64kB max 32MB */
|
||||
{
|
||||
printf("Impossibly large memory size %x\n",newsz);
|
||||
return -1;
|
||||
}
|
||||
f=fopen(argv[1],"rb");
|
||||
if(!f)
|
||||
{
|
||||
printf("Unable to open file\n");
|
||||
return -1;
|
||||
}
|
||||
fseek(f,0,SEEK_END);
|
||||
sz=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
buf=malloc(sz);
|
||||
if(!buf)
|
||||
{
|
||||
printf("Unable to allocate temporary buffer\n");
|
||||
fclose(f);
|
||||
return -1;
|
||||
}
|
||||
fread(buf,1,sz,f);
|
||||
fclose(f);
|
||||
f=fopen(argv[1],"wb");
|
||||
*((unsigned long *)(buf+OFF))=newsz;
|
||||
fwrite(buf,1,sz,f);
|
||||
fclose(f);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user