Commit cd40899e authored by Matthew Burket's avatar Matthew Burket

fix somethings

parent 4964af40
......@@ -12,13 +12,8 @@
</component>
<component name="ChangeListManager">
<list default="true" id="36048fb3-fc75-499f-9004-4a458a9d082e" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/dictionaries/mburket.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dictionaries/mburket.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/buffer.c" beforeDir="false" afterPath="$PROJECT_DIR$/buffer.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/buffer.h" beforeDir="false" afterPath="$PROJECT_DIR$/buffer.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/connect.c" beforeDir="false" afterPath="$PROJECT_DIR$/connect.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/connect.h" beforeDir="false" afterPath="$PROJECT_DIR$/connect.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.c" beforeDir="false" afterPath="$PROJECT_DIR$/main.c" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/cmake-build-debug/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
......@@ -34,8 +29,8 @@
<file leaf-file-name="buffer.c" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/buffer.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="297">
<caret line="62" selection-start-line="62" selection-end-line="62" />
<state relative-caret-position="435">
<caret line="41" column="39" selection-start-line="41" selection-start-column="39" selection-end-line="41" selection-end-column="39" />
<folding>
<element signature="e#40#59#0" expanded="true" />
</folding>
......@@ -43,11 +38,11 @@
</provider>
</entry>
</file>
<file leaf-file-name="connect.c" pinned="false" current-in-tab="true">
<file leaf-file-name="connect.c" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/connect.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="280">
<caret line="66" column="46" selection-start-line="66" selection-start-column="46" selection-end-line="66" selection-end-column="46" />
<state relative-caret-position="370">
<caret line="71" column="27" selection-start-line="71" selection-start-column="27" selection-end-line="71" selection-end-column="27" />
<folding>
<element signature="e#42#62#0" expanded="true" />
</folding>
......@@ -55,10 +50,19 @@
</provider>
</entry>
</file>
<file leaf-file-name=",gitignore" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/,gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="334">
<caret line="84" column="18" selection-start-line="84" selection-start-column="18" selection-end-line="84" selection-end-column="18" />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="main.c" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/main.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="603">
<state relative-caret-position="703">
<caret line="57" selection-start-line="57" selection-end-line="57" />
<folding>
<element signature="e#0#19#0" expanded="true" />
......@@ -100,11 +104,11 @@
<option value="$PROJECT_DIR$/LICENSE" />
<option value="$PROJECT_DIR$/CMakeLists.txt" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/,gitignore" />
<option value="$PROJECT_DIR$/buffer.c" />
<option value="$PROJECT_DIR$/connect.h" />
<option value="$PROJECT_DIR$/main.c" />
<option value="$PROJECT_DIR$/connect.c" />
<option value="$PROJECT_DIR$/buffer.c" />
<option value="$PROJECT_DIR$/,gitignore" />
</list>
</option>
</component>
......@@ -182,26 +186,26 @@
<workItem from="1520536552677" duration="1731000" />
<workItem from="1522346739296" duration="3244000" />
<workItem from="1523115745573" duration="9472000" />
<workItem from="1523128673229" duration="2438000" />
<workItem from="1523128673229" duration="3157000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="16885000" />
<option name="totallyTimeSpent" value="17604000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="27" width="2560" height="1573" extended-state="6" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.12066246" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.12066246" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Messages" order="7" weight="0.33053222" />
<window_info anchor="bottom" id="CMake" order="7" />
<window_info anchor="bottom" id="Event Log" order="7" side_tool="true" />
<window_info anchor="bottom" id="Version Control" order="7" />
<window_info active="true" anchor="bottom" id="Run" order="2" visible="true" weight="0.32843137" />
<window_info anchor="bottom" id="Run" order="2" weight="0.32843137" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Terminal" order="7" weight="0.32983193" />
<window_info anchor="bottom" id="Terminal" order="7" visible="true" weight="0.32983193" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39985994" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
......@@ -398,13 +402,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/,gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="304">
<caret line="84" column="18" selection-start-line="84" selection-start-column="18" selection-end-line="84" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/CMakeLists.txt">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
......@@ -438,7 +435,7 @@
</entry>
<entry file="file://$PROJECT_DIR$/main.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="603">
<state relative-caret-position="703">
<caret line="57" selection-start-line="57" selection-end-line="57" />
<folding>
<element signature="e#0#19#0" expanded="true" />
......@@ -448,8 +445,8 @@
</entry>
<entry file="file://$PROJECT_DIR$/buffer.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="297">
<caret line="62" selection-start-line="62" selection-end-line="62" />
<state relative-caret-position="435">
<caret line="41" column="39" selection-start-line="41" selection-start-column="39" selection-end-line="41" selection-end-column="39" />
<folding>
<element signature="e#40#59#0" expanded="true" />
</folding>
......@@ -458,13 +455,20 @@
</entry>
<entry file="file://$PROJECT_DIR$/connect.c">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="280">
<caret line="66" column="46" selection-start-line="66" selection-start-column="46" selection-end-line="66" selection-end-column="46" />
<state relative-caret-position="370">
<caret line="71" column="27" selection-start-line="71" selection-start-column="27" selection-end-line="71" selection-end-column="27" />
<folding>
<element signature="e#42#62#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/,gitignore">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="334">
<caret line="84" column="18" selection-start-line="84" selection-start-column="18" selection-end-line="84" selection-end-column="18" />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -13,6 +13,9 @@ void initBuffer(GrowthBuffer *arr, size_t initSize) {
arr->array = (char *) malloc(sizeof(char) * initSize);
arr->total_size = initSize;
arr->used = 0;
for (int i = 0; i < initSize; i++) {
arr->array[i]= '\0';
}
}
/// Appends to the buffer
......@@ -35,7 +38,10 @@ int appendBuffer(GrowthBuffer *arr, char *value, int length) {
int arrNewSize = growthFactor * 2;
// realloc the array
char *newArr = realloc(arr->array, dLength * sizeof(char));
char *newArr = realloc(arr->array, arrNewSize * sizeof(char));
for (int i = arr->total_size + 1; i < arrNewSize; i++) {
arr->array[i]= '\0';
}
// Set the new array
arr->array = newArr;
// Set the new total size
......@@ -63,6 +69,7 @@ int appendBuffer(GrowthBuffer *arr, char *value, int length) {
}
/// Free the memory used by the buffer
///
/// \param arr buffer to free
......
......@@ -69,7 +69,7 @@ int execate_request(int socketfd, char *hostname, char *path, int head) {
// Reqeust is a buffer
GrowthBuffer request;
// Init the buffer
initBuffer(&request, 500);
initBuffer(&request, 50);
// Figure out the verb
char *firstLine;
if (head) {
......@@ -92,7 +92,7 @@ int execate_request(int socketfd, char *hostname, char *path, int head) {
appendBuffer(&request, "\r\n", 2);
// Send the request
ssize_t sentByte = send(socketfd, request.array, strlen(request.array), 0);
printf("%s", request.array);
freeBuffer(&request);
return sentByte;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment