Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolved Warnings #6

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions src/mem.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Expand All @@ -8,8 +7,6 @@

#include "../cutils.h"



#define MAX_PTRS 8192

typedef struct {
Expand Down Expand Up @@ -97,15 +94,24 @@ void* dbg_calloc(size_t nmemb, size_t size, char* file, int line)
return ptr;
}

void* dbg_realloc(void* ptr, size_t size, char* file, int line)
{
void* dbg_realloc(void* ptr, size_t size, char* file, int line) {
dbg(4, "dbg_realloc: %s:%d %p %zu->%zu bytes", file, line, ptr, malloc_usable_size(ptr), size);

// Unlog the pointer before reallocating
unlog_ptr(ptr, file, line);

// Reallocate memory
void* newptr = realloc(ptr, size);

// Check for allocation failure
if (newptr == NULL) {
msg(ERROR, "\trealloc failed");
return NULL; // Return NULL on failure
}
unlog_ptr(ptr, file, line);

// Log the new pointer
log_ptr(newptr, file, line);

return newptr;
}

Expand Down Expand Up @@ -136,4 +142,3 @@ void dbg_free(void* ptr, char* file, int line)
}
free(ptr);
}

5 changes: 3 additions & 2 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ int mvlink(char* old_path,char* new_path)
//strncpy(new_link,parent_path,strlen(parent_path));

// add the separator
if (new_link[strlen(new_link)-1] != '/') strncat(new_link,"/",1);
if (new_link[strlen(new_link) - 1] != '/') {
strncat(new_link, "/", 2); // Reserve space for the null terminator
}

//strncat(new_link,rel_path,strlen(rel_path));

Expand Down Expand Up @@ -289,4 +291,3 @@ int mvsp(char* old_path,char* new_path)

return 0;
}

Loading