Skip to content

Commit b48b669

Browse files
author
Wei Li
committed
compatible ceil divide
1 parent bf0d9b1 commit b48b669

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

proxylab-handout/dstring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "dstring.h"
2-
#include <math.h>
32
#include <string.h>
43

54
#define DEFAULT_LENGTH 1024
@@ -24,7 +23,9 @@ void string_free(string *pstr)
2423
*/
2524
inline static size_t ceil_divide(size_t a, size_t b)
2625
{
27-
return (size_t)(ceil((float)a / (float) b));
26+
size_t m = 2;
27+
for (m = 2; m * b < a; m+=1) {}
28+
return m;
2829
}
2930

3031
/* string_append : append cstr to the end of pstr.

proxylab-handout/proxy.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ void forward_response(int infd, int outfd)
4949
string_malloc(&response);
5050

5151
while (Rio_readlineb(&rio, buf, MAXLINE)) {
52-
printf("%s\n", buf);
5352
string_append(&response, buf);
5453
}
5554
#ifdef DEBUG

0 commit comments

Comments
 (0)