[insert project logo here (125x200px max)]

Navigator

Mailinglists

Please report any errors or ommissions you find to our `Help' mailinglist, or post a message in the Forums.

Copyright and Licensing Information

Snap is (c) Jonathan T. Moore, 1999-2002 and licensed under the GNU General Public License (GPL).

All other parts of Splash are (c) Willem de Bruijn, 2002-2003 and licensed under the BSD Open Source License.

All sourcecode is made publicly available.

Acknowledgement

Splash and the Splash website are hosted by SourceForge.net

SourceForge.net Logo

osi-open source certified logo

Splash - Documentation

SNMP Plus a Lightweight API for SNAP Handling

Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

snap_svc/snap_svc_memmap_hash_list.c

Go to the documentation of this file.
00001 /* snap-1.0. Copyright (C) 2000 by Jonathan T. Moore and Michael Hicks.
00002  *
00003  * list.c : routines for manipulating SNAP lists
00004  *
00005  * $Id: snap_svc_memmap_hash_list.c,v 1.1 2003/04/03 12:42:46 wdebruij Exp $
00006  */
00007 
00008 #include <stdlib.h>
00009 #include "snap_svc_memmap_hash_list.h"
00010 
00011 #ifndef _SNAP_LIST_T
00012 typedef struct l {
00013   void *v;
00014   struct l *next;
00015 } list_t;
00016 #define _SNAP_LIST_T
00017 #endif /* !_SNAP_LIST_T */
00018 
00019 list_t *cons(void *v, list_t *next) {
00020   list_t *cell;
00021   
00022 #ifdef __KERNEL__
00023   cell = (list_t *)kmalloc(sizeof(list_t),GFP_ATOMIC);
00024   if (!cell) {
00025     printk(KERN_WARNING "%s:%d: kmalloc failed\n",__FILE__,__LINE__);
00026     return NULL;
00027   }
00028 #else
00029   memalloc(cell,list_t *,sizeof(list_t));
00030 #endif /* __KERNEL__ */
00031   cell->v = v;
00032   cell->next = next;
00033   return cell;
00034 }
00035 
00036 void free_list(list_t *list) {
00037   list_t *iter = list, *tmp;
00038   while (iter != NULL) {
00039     tmp = iter;
00040 #ifdef __KERNEL__
00041     kfree(iter);
00042 #else
00043     free(iter);
00044 #endif /* __KERNEL__ */
00045     iter = tmp->next;
00046   }
00047 }
00048 
00049 int length_list(list_t *list) {
00050   int i = 0;
00051   list_t *iter = list;
00052   while (iter != NULL) {
00053     i++;
00054     iter = iter->next;
00055   }
00056   return i;
00057 }
00058