Unverified Commit 5935caff authored by Mihai Fufezan's avatar Mihai Fufezan
Browse files

xcur2png: fix cross-build

Fixes errors caused by autoconf not finding rpl_malloc

/nix/store/vl7wj0kj6rq3lgn7czb266lbr5y26kfn-aarch64-unknown-linux-gnu-binutils-2.42/bin/aarch64-unknown-linux-gnu-ld: /build/source/xcur2png.c:230:(.text+0x91c): undefined reference to `rpl_malloc'
parent cdce9531
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -11,6 +11,11 @@ stdenv.mkDerivation rec {
    sha256 = "0858wn2p14bxpv9lvaz2bz1rk6zk0g8zgxf8iy595m8fqv4q2fya";
  };

  patches = [
    # https://github.com/eworm-de/xcur2png/pull/3
    ./malloc.diff
  ];

  nativeBuildInputs = [
    pkg-config
  ];
+33 −0
Original line number Diff line number Diff line
--- a/xcur2png.c
+++ b/xcur2png.c
@@ -16,7 +16,10 @@
 /* Todo: atoi error handling */
 /* help is -h in manual */

+#if HAVE_CONFIG_H
 #include <config.h>
+#endif
+#undef malloc

 #define _ATFILE_SOURCE
 #include <stdio.h>
@@ -34,6 +37,19 @@
 #include <png.h>
 #include <X11/Xcursor/Xcursor.h>

+
+void *malloc ();
+
+/* Allocate an N-byte block of memory from the heap.
+   If N is zero, allocate a 1-byte block.  */
+
+void* rpl_malloc (size_t n)
+{
+  if (n == 0)
+    n = 1;
+  return malloc (n);
+}
+
 #define PNG_SETJMP_NOT_SUPPORTED 1
 
 #define PROGRESS_SHARPS 50 /* total number of progress sharps */