From 4846ad16579f7fcf06fe01e03a56815b2d8c4a93 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 7 Jan 2009 22:52:33 +0000 Subject: Introduce nitems() and use it; use bsearch. --- client-msg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'client-msg.c') diff --git a/client-msg.c b/client-msg.c index 65287f50..c1e28ecb 100644 --- a/client-msg.c +++ b/client-msg.c @@ -1,4 +1,4 @@ -/* $Id: client-msg.c,v 1.14 2007-12-06 09:46:21 nicm Exp $ */ +/* $Id: client-msg.c,v 1.15 2009-01-07 22:52:33 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -43,7 +43,6 @@ struct client_msg client_msg_table[] = { { MSG_EXIT, client_msg_fn_exit }, { MSG_EXITED, client_msg_fn_exited } }; -#define NCLIENTMSG (sizeof client_msg_table / sizeof client_msg_table[0]) int client_msg_dispatch(struct client_ctx *cctx, char **error) @@ -59,7 +58,7 @@ client_msg_dispatch(struct client_ctx *cctx, char **error) return (1); buffer_remove(cctx->srv_in, sizeof hdr); - for (i = 0; i < NCLIENTMSG; i++) { + for (i = 0; i < nitems(client_msg_table); i++) { msg = client_msg_table + i; if (msg->type == hdr.type) { if (msg->fn(&hdr, cctx, error) != 0) -- cgit