Skip to content

Commit

Permalink
Merge pull request #104 from Okkonen-GitHub/main
Browse files Browse the repository at this point in the history
Add debug build recipe to makefile
  • Loading branch information
AleksArt000 authored Jul 26, 2024
2 parents b39a904 + 45a7b90 commit 87c51c7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/cutils
Submodule cutils updated 3 files
+ cutils.a
+68 −1 cutils.h
+136 −0 src/hashtable.c
11 changes: 9 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ SDIR = src



CFLAGS = -Wall -g -fPIC -O2 -Wextra -L./bin -Iinclude
CFLAGS = -Wall -fPIC -O2 -Wextra -L./bin -Iinclude
DBGFLAGS = -g -fsanitize=address

# set local lib to lib/*/*.a
LOCAL_LIBS = $(wildcard lib/*/*.a)
Expand Down Expand Up @@ -83,11 +84,17 @@ check: test check-all
@echo "All Tests Passed"


# This will conflict with other artifacts so you should run make clean before `make debug` and after you're done
debug: CFLAGS += $(DBGFLAGS)
debug: MEMCHECK = 1
debug: libs $(BINDIR)/$(LIBOUT) formats
@echo "Build done (debug)"

libs:
for i in $(LOCAL_LIBS); do make -C $$(dirname $$i) all; done

direct:
$(CC) $(CFLAGS) $(SRCS) $(LIBS) -g -shared -fPIC -o $(LIBOUT)
$(CC) $(CFLAGS) $(SRCS) $(LIBS) -g -shared -fPIC -o $(BINDIR)/$(LIBOUT)

formats:
@echo "Building formats..."
Expand Down
3 changes: 2 additions & 1 deletion src/hashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ hashtable* hm_create(int capacity)
hashtable *hm = calloc(1,sizeof(hashtable));
hm->items = calloc(capacity, sizeof(item));
if (hm->items == NULL) {
free(hm);
fprintf(stderr, "Out of memory");
exit(1);
}
Expand Down Expand Up @@ -134,4 +135,4 @@ unsigned int hm_hash(hashtable *hm, char *key)
//printf("hash: %d\n", h % hm->capacity);

return h % hm->capacity;
}
}

0 comments on commit 87c51c7

Please sign in to comment.