ref: 46b3adb7a4861c9b0209421a078b48819b22a8c7
parent: ca37f120431bd7678e4eedb936248c5e3234aa88
author: Halfwit <michaelmisch1985@gmail.com>
date: Thu Oct 26 17:38:54 PDT 2017
Popping some changes to github Signed-off-by: Halfwit <michaelmisch1985@gmail.com>
--- a/bin_utils.c
+++ b/bin_utils.c
@@ -41,13 +41,21 @@
}
// given in[], seperate by even and odd into a[] and b[]
-void split(struct Input in[], struct Input a[], struct Input b[], size_t length) {
+void split(struct Input *in, struct Input *a, struct Input *b, size_t length) {
bool bin_switch = true;
for (size_t i = 0; i < length; i++) {
if (bin_switch) {
- a[i/2] = in[i];
+ a[i/2].minw = in[i].minw;
+ a[i/2].minh = in[i].minh;
+ a[i/2].maxw = in[i].maxw;
+ a[i/2].maxh = in[i].maxh;
+ a[i/2].wid = in[i].wid;
} else {
- b[i/2] = in[i];
+ b[i/2].minw = in[i].minw;
+ b[i/2].minh = in[i].minh;
+ b[i/2].maxw = in[i].maxw;
+ b[i/2].maxh = in[i].maxh;
+ b[i/2].wid = in[i].wid;
}
bin_switch = !bin_switch;
}
--- a/binpack.h
+++ b/binpack.h
@@ -20,7 +20,7 @@
void binary_bin_pack(unsigned width, unsigned height, struct Output out[], struct Input in[]);
bool bin_pack(unsigned width, unsigned height, struct Output out[], struct Input in[]);
-void split(struct Input in[], struct Input a[], struct Input b[], size_t length);
+void split(struct Input *in, struct Input *a, struct Input *b, size_t length);
void center(unsigned width, unsigned height, struct Output out[], unsigned gaps);
void sort_bins(struct Input r[], const size_t length);
void print_bin(struct Output out[], size_t length);
--- a/main.c
+++ b/main.c
@@ -54,14 +54,14 @@
return EXIT_SUCCESS;
}
/* More than one screen will need a few more data types */
- struct Input in_a[MAX_BIN/2], in_b[MAX_BIN/2];
- struct Output out_a[MAX_BIN/2], out_b[MAX_BIN/2];
+ struct Input in_a[MAX_BIN/2 + 1], in_b[MAX_BIN/2 + 1];
+ struct Output out_a[MAX_BIN/2 + 1], out_b[MAX_BIN/2 + 1];
/* Sort into two bins and pack each seperately */
if (screens == 2) {
split(input, in_a, in_b, length);
- for (size_t i = 0; i < (length/2) - 1; i ++) {
- printf("a %z b %z\n", in_a[i], in_b[i]);
+ for (size_t i = 0; i <= sizeof(*in_a)/sizeof(in_a[0]); i++) {
+ printf("a %d b %d\n", in_a[i].maxw, in_b[i].maxw);
}
/* binpack.c */
binary_bin_pack(width/2, height, out_a, in_a);