HTList_map macro

------- Forwarded Message

Return-Path: w3c-lib-request@w3.org 
Return-Path: <w3c-lib-request@w3.org>
Received: from www10.w3.org by www18.w3.org (5.0/NSCS-1.0S) 
	id AA09600; Thu, 9 May 1996 12:57:24 +0500
Received: from www19.w3.org by www10.w3.org (5.0/NSCS-1.0S) 
	id AA22263; Thu, 9 May 1996 12:57:24 +0500
Received: by www19.w3.org (8.6.12/8.6.12) id MAA27931 for frystyk@w3.org; 
Thu, 9 May 1996 12:57:22 -0400
Received: from www10.w3.org by www19.w3.org (8.6.12/8.6.12) with SMTP id 
MAA27640 for <w3c-lib@www19.w3.org>; Thu, 9 May 1996 12:56:43 -0400
Received: from GOOFY.FI.UPM.ES by www10.w3.org (5.0/NSCS-1.0S) 
	id AA22200; Thu, 9 May 1996 12:56:14 +0500
Received: from sol.dia.fi.upm.es by relay.fi.upm.es (PMDF V5.0-7 #15665)
 id <01I4IGCRCGS20004B2@relay.fi.upm.es> for w3c-lib@w3.org; Thu,
 09 May 1996 18:54:38 +0200 (MET-DST)
Received: by sol.dia.fi.upm.es (4.1/3.1) Thu, 9 May 96 18:54:37 +0200
Date: Thu, 9 May 1996 12:57:22 -0400
X-Envelope-From: sacha@clip.dia.fi.upm.es  Thu May  9 12:56:44 1996
Old-Date: Thu, 09 May 1996 18:54:37 +0200
From: sacha@clip.dia.fi.upm.es (Sacha)
Subject: HTList_map macro
To: w3c-lib@w3.org
Message-Id: <9605091654.AA04048@sol.dia.fi.upm.es>
Mime-Version: 1.0
Content-Transfer-Encoding: 7BIT
X-Diagnostic: Not on the accept list
X-Envelope-To: w3c-lib
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-Length: 645



Here's a macro to map a function over an HTList:

#define HTList_map(list_p,func_p,data_p) \
  { \
     HTList* l_p = list_p; \
     void* obj_p; \
    \
     while ((obj_p = HTList_nextObject(l_p)) && (*func_p)(obj_p,data_p)); \
  }


func_p is a function which returns an int. HTList_map stops if the
value returned by the function is FALSE (NO).

Data can be passed to/from HTList_map using the data_p argument.

P.S. This is virtually the first C macro I've ever written so if there's
any way to improve it (e.g. type checking) please let me know. Also, will
the { } ensure that it uses the local variables l_p and obj_p?

Later,

Sacha.


------- End of Forwarded Message


-- 
Henrik Frystyk Nielsen, <frystyk@w3.org>
World-Wide Web Consortium, MIT/LCS NE43-356
545 Technology Square, Cambridge MA 02139, USA

Received on Friday, 31 May 1996 12:18:23 UTC