Advertisement
Guest User

Diff to create usable test

a guest
Apr 3rd, 2016
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. $ diff -u original_onlyjob.c usable_onlyjob.c
  2. --- original_onlyjob.c 2016-04-03 11:30:29.113618080 -0400
  3. +++ usable_onlyjob.c 2016-04-03 13:41:24.235069236 -0400
  4. @@ -7,24 +7,24 @@
  5.  
  6. setbuf(stdout,NULL); //disable output buffering
  7.  
  8. -char *str=malloc(8);
  9. +char *str=malloc(9);
  10. strcpy(str,"abcdefgh");
  11.  
  12. -str=realloc(str,strlen(str)+8);
  13. +str=realloc(str,strlen(str)+1+8);
  14. strcat(str,"efghefgh"); //sprintf(str,"%s%s",str,"efghefgh");
  15.  
  16. -int imax=1024/strlen(str)*1024*4;
  17. +unsigned int imax=1024/strlen(str)*1024*4;
  18.  
  19. printf("%s","exec.tm.sec\tstr.length\n"); //fflush(stdout);
  20.  
  21. time_t starttime=time(NULL);
  22. char *gstr=malloc(0);
  23. -int i=0;
  24. +unsigned int i=0;
  25. char *pos;
  26. -int lngth;
  27. +size_t lngth;
  28.  
  29. char *pos_c=gstr;
  30. -int str_len=strlen(str);
  31. +size_t str_len=strlen(str);
  32.  
  33. while(i++ < imax+1000){
  34. lngth=strlen(str)*i;
  35. @@ -33,12 +33,12 @@
  36. pos_c+=str_len;
  37.  
  38. pos=gstr;
  39. - while(pos=strstr(pos,"efgh")){
  40. + while((pos=strstr(pos,"efgh"))){
  41. memcpy(pos,"____",4);
  42. }
  43.  
  44. if(lngth % (1024*256)==0){
  45. - printf("%dsec\t\t%dkb\n",time(NULL)-starttime,lngth/1024); //fflush(stdout);
  46. + printf("%lusec\t\t%lukb\n",time(NULL)-starttime,lngth/1024); //fflush(stdout);
  47. }
  48. }
  49. //printf("%s\n",gstr);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement