]> sigrok.org Git - libsigrok.git/commitdiff
Add ARRAY_SIZE helper.
authorUwe Hermann <redacted>
Mon, 12 Apr 2010 22:34:20 +0000 (00:34 +0200)
committerUwe Hermann <redacted>
Mon, 12 Apr 2010 22:34:20 +0000 (00:34 +0200)
hardware/zeroplus-logic-cube/zeroplus.c
sigrok.h

index 4a1e46fcf7cf0f7dfe6e13661cec0cf85af00f72..e5b05ac6c5725e9d078aaa23800bdfc5902cb2e7 100644 (file)
@@ -156,7 +156,7 @@ struct sigrok_device_instance *zp_open_device(int device_index)
                        if(des.idVendor == USB_VENDOR) {
                                if(libusb_get_bus_number(devlist[i]) == sdi->usb->bus &&
                                                libusb_get_device_address(devlist[i]) == sdi->usb->address) {
-                                                       for (j = 0; j < sizeof(zeroplus_models) / sizeof(zeroplus_models[0]); j++) {
+                                                       for (j = 0; j < ARRAY_SIZE(zeroplus_models); j++) {
                                                                if (des.idProduct == zeroplus_models[j].pid) {
                                                                        g_message("Found PID=%04X (%s)", des.idProduct, zeroplus_models[j].model_name);
                                                                        num_channels = zeroplus_models[j].channels;
index 1eedd8bca75b5b81c276cf8cb342afe8e414f973..4b6e2640d69468d2eb1f99c45f6aa11f01902178 100644 (file)
--- a/sigrok.h
+++ b/sigrok.h
 #define MHZ(n) (n * 1000000)
 #define GHZ(n) (n * 1000000000)
 
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+#endif
+
 /* Data types, used by hardware plugins for set_configuration() */
 enum {
        T_UINT64,