Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void LlenarMemoria (void *p, size_t cont, unsigned char byte)
- {
- unsigned char *arr=(unsigned char *) p;
- size_t i;
- for (i=0; i<cont;i++)
- arr[i]=byte;
- }
- void cmdMemfill(){
- char A='A';
- int Bytes=128;
- int *p,i;
- if(numtrozos==1){
- return;
- }if(numtrozos>2){
- Bytes=atoi(trozos[2]);
- }
- if(numtrozos>3){
- A=trozos[3][0];
- }
- if(nbloq!=0 || nshared!=0){
- if(nbloq!=0){
- char comp[20];
- sprintf(comp,"%p",histBloqElemento(0)->dir);
- for(i=0;i<nbloq && strcmp(comp,trozos[1])!=0 ;i++){
- if(i!=nbloq-1){
- sprintf(comp,"%p",histBloqElemento(i+1)->dir);
- }
- }
- }
- if(i<nbloq && nbloq!=0){
- p=histBloqElemento(i)->dir;
- if(histBloqElemento(i)->Bytes<Bytes){
- printf("Violacion de segmento generado\n");
- exit(0);
- }
- }else if(nshared!=0){
- char comp2[20];
- sprintf(comp2,"%p",histSharedElemento(0)->dir);
- for(i=0;i<nshared && strcmp(comp2,trozos[1])!=0 ;i++){
- if(i!=nshared-1){
- sprintf(comp2,"%p",histSharedElemento(i+1)->dir);
- }
- }
- if(i<nshared){
- p=histSharedElemento(i)->dir;
- if(histSharedElemento(i)->Bytes<Bytes){
- printf("Violacion de segmento generado\n");
- exit(0);
- }
- }else{
- printf("Violacion de segmento generado\n");
- exit(0);
- }
- }else{
- printf("Violacion de segmento generado\n");
- exit(0);
- }
- }else{
- printf("Violacion de segmento generado\n");
- exit(0);
- }
- printf("Llenando %d bytes de memoria con el byte %c(%02x) a partir de la direccion %p\n",Bytes,A,A,p);
- LlenarMemoria(p,Bytes,(unsigned char)A);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement