diff options
| author | ame <[email protected]> | 2024-02-13 14:14:20 -0600 |
|---|---|---|
| committer | ame <[email protected]> | 2024-02-13 14:14:20 -0600 |
| commit | cec56b5d601c3f3f09841dd0c24cae6ea3d734d8 (patch) | |
| tree | 4ca0fc810be6265be8c5ee00f592e64af8c8058e /src | |
| parent | 04b1b0fc52287228a2c9bc6a3cbf9a85bdd1f2fc (diff) | |
idk
Diffstat (limited to 'src')
| -rw-r--r-- | src/i_str.c | 1 | ||||
| -rw-r--r-- | src/i_util.c | 1 | ||||
| -rw-r--r-- | src/lua.c | 23 | ||||
| -rw-r--r-- | src/lua.h | 4 | ||||
| -rw-r--r-- | src/net.c | 6 | ||||
| -rw-r--r-- | src/parray.c | 1 |
6 files changed, 25 insertions, 11 deletions
diff --git a/src/i_str.c b/src/i_str.c index 5b12a3f..d77067b 100644 --- a/src/i_str.c +++ b/src/i_str.c @@ -1,4 +1,5 @@ #include "i_str.h" +#include "lua.h" str* str_init(char* init){ if(init == NULL){ diff --git a/src/i_util.c b/src/i_util.c index 0a20224..48749d7 100644 --- a/src/i_util.c +++ b/src/i_util.c @@ -2,6 +2,7 @@ #include <stdio.h> #include <stdlib.h> #include "lua.h" + void p_fatal(const char* m){ fprintf(stderr, "%s[ fatal ] %s %s\n",color_red, m, color_reset); exit(EXIT_FAILURE); @@ -7,6 +7,19 @@ #include "parray.h"
static int ii = 0;
+static int malloc_count = 0;
+
+void* __malloc_(size_t N){
+ printf("hi");
+ malloc_count++;
+ return (malloc)(N);
+}
+
+void __free_(void* p){
+ malloc_count--;
+ printf("%i\n",malloc_count);
+ return (free)(p);
+}
int writer(lua_State *L, const void* p, size_t sz, void* ud){
char o[2] = {0};
@@ -55,15 +68,7 @@ void i_dcopy(lua_State* src, lua_State* dest, void* _seen){ lua_pop(dest, 1);
lua_rawgeti(dest, LUA_REGISTRYINDEX, *(int*)whar);
- //lua_pushnumber(dest, 23);
- /*int abb = lua_gettop(src);
- l_pprint(src);
- lua_settop(src, abb);
- abb = lua_gettop(dest);
- printf("\n**\n");
- l_pprint(dest);
- lua_settop(dest, abb);
- printf("used %i\n",*(int*)whar);*/
+
return;
}
//lua_pushinteger(dest, 55);
@@ -1,6 +1,10 @@ #include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
+#include <stdlib.h>
+
+void* __malloc_(size_t);
+void __free_(void*);
void i_dcopy(lua_State* src, lua_State* dest, void*);
@@ -397,6 +397,7 @@ void* handle_client(void *_arg){ void* v = parray_find(paths, aa->c);
+ str_free(aa);
if(v == NULL){
str* resp;
http_build(&resp, 404, "Not Found","text/html", "<h1>404</h1>");
@@ -461,7 +462,7 @@ void* handle_client(void *_arg){ }
}
}
- parray_lclear(owo);
+ parray_lclear(owo); //dont free the rest
lua_pushstring(L, "client_fd");
lua_gettable(L, res_idx);
@@ -471,7 +472,7 @@ void* handle_client(void *_arg){ }
- for(int i = 0; i != len; i++){
+ for(int i = 0; i != len * 2; i++){
str_free(table[i]);
}
free(table);
@@ -556,6 +557,7 @@ int start_serv(lua_State* L, int port){ pthread_create(&thread_id, NULL, handle_client, (void*)args);
pthread_detach(thread_id);
+ free(client_fd);
}
}
diff --git a/src/parray.c b/src/parray.c index d0e38ff..77c9771 100644 --- a/src/parray.c +++ b/src/parray.c @@ -3,6 +3,7 @@ #include <stdlib.h>
#include <string.h>
+#include "lua.h"
#include "parray.h"
parray_t* parray_init(){
|
