From: Uwe Hermann Date: Mon, 12 Apr 2010 22:34:20 +0000 (+0200) Subject: Add ARRAY_SIZE helper. X-Git-Tag: libsigrok-0.1.0~564 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=fdd20b52391b9d491b37fb7d3e157ea5db098062;p=libsigrok.git Add ARRAY_SIZE helper. --- diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 4a1e46fc..e5b05ac6 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -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; diff --git a/sigrok.h b/sigrok.h index 1eedd8bc..4b6e2640 100644 --- a/sigrok.h +++ b/sigrok.h @@ -54,6 +54,10 @@ #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,