Mercurial
diff dowa/d_memory.c @ 32:08a465eec50b
[Dowa] Fixed a bug that I caused trying to stop memory leak lol.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 09 Oct 2025 07:03:36 -0700 |
| parents | 947b81010aba |
| children | 84672efec192 |
line wrap: on
line diff
--- a/dowa/d_memory.c Thu Oct 09 06:55:07 2025 -0700 +++ b/dowa/d_memory.c Thu Oct 09 07:03:36 2025 -0700 @@ -360,8 +360,8 @@ if (!f) { perror("fopen"); continue; } void *buf = p_hash_map->p_arena ? - Dowa_Arena_Allocate(p_hash_map->p_arena, size+1) : - malloc(size+1); + Dowa_Arena_Allocate(p_hash_map->p_arena, size) : + malloc(size); if (!buf) { perror("malloc"); fclose(f); closedir(dir); return -1; } @@ -374,10 +374,7 @@ } fclose(f); - // null-terminate since the files don't do this and we need this for print. - ((unsigned char*)buf)[size] = '\0'; - - Dowa_HashMap_Push_Value_With_Type(p_hash_map, entry->d_name, buf, size + 1, DOWA_HASH_MAP_TYPE_STRING); + Dowa_HashMap_Push_Value_With_Type(p_hash_map, entry->d_name, buf, size, DOWA_HASH_MAP_TYPE_STRING); free(buf); // Dowa_HashMap_PushValue made its own copy } else if (S_ISDIR(st.st_mode))