Fix binstr_to_int loop bug. Add lf prefix
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "binarytree.h"
|
||||
#include "lfbinarytree.h"
|
||||
|
||||
void bintree_init(BinTree *tree, void (*destroy)(void *data)) {
|
||||
tree->size = 0;
|
@ -7,7 +7,7 @@
|
||||
#include <bsd/stdlib.h>
|
||||
#endif
|
||||
|
||||
#include "input.h"
|
||||
#include "lfinput.h"
|
||||
|
||||
char *get_input(const char *path) {
|
||||
FILE *fp = NULL;
|
||||
@ -67,7 +67,7 @@ int *get_ints(const char *path, size_t *sz) {
|
||||
for (size_t idx = 0; idx < *sz; idx++) {
|
||||
int n;
|
||||
const char *errstr;
|
||||
n = strtonum(lines[idx], INT_MIN, INT_MAX, &errstr);
|
||||
n = (int)strtonum(lines[idx], INT_MIN, INT_MAX, &errstr);
|
||||
if (errstr) {
|
||||
printf("Failed to convert %s to int. Returning NULL\n", lines[idx]);
|
||||
exit(1);
|
@ -1,7 +1,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "linkedlist.h"
|
||||
#include "lflinkedlist.h"
|
||||
|
||||
void ll_init(List* list, void (*destroy)(void *data)) {
|
||||
list->size = 0;
|
@ -1,6 +1,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "math.h"
|
||||
#include "lfmath.h"
|
||||
|
||||
int max_int(int a, int b) {
|
||||
if (a > b) {
|
||||
@ -18,7 +18,7 @@ int min_int(int a, int b) {
|
||||
|
||||
int binstr_to_int(const char *s) {
|
||||
int n = 0, m = 1;
|
||||
for (size_t i = strlen(s) - 1; i >= 0; --i) {
|
||||
for (int i = (int)strlen(s) - 1; i >= 0; --i) {
|
||||
if (s[i] == '1') {
|
||||
n += m;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "set.h"
|
||||
#include "lfset.h"
|
||||
|
||||
void set_init(Set* set, int (*match)(const void* a, const void* b),
|
||||
void (*destroy)(void* data)) {
|
@ -1,4 +1,4 @@
|
||||
#include "stack.h"
|
||||
#include "lfstack.h"
|
||||
|
||||
void stack_init(Stack* stack, void (*destroy)(void* data)) {
|
||||
ll_init(stack, destroy);
|
Reference in New Issue
Block a user