ADC Home > Reference Library > Reference > Darwin > Miscellaneous User Space API Reference

 


tools.h

Introduction

@defgroup util Memory Utility Routines @ingroup library @{



#defines


SNMP_FREE


#define SNMP_FREE(
    s) do {
    if (
    s) {
    free((
    void *)s); s=NULL; } 
} while(
    0) 
Discussion

@def SNMP_FREE(s) Frees a pointer only if it is !NULL and sets its value to NULL


SNMP_MALLOC_STRUCT


#define SNMP_MALLOC_STRUCT(
    s)  
Discussion

@def SNMP_MALLOC_STRUCT(s) Mallocs memory of sizeof(struct s), zeros it and returns a pointer to it.


SNMP_MALLOC_TYPEDEF


#define SNMP_MALLOC_TYPEDEF(
    td)  
Discussion

@def SNMP_MALLOC_TYPEDEF(t) Mallocs memory of sizeof(t), zeros it and returns a pointer to it.


SNMP_MAX


#define SNMP_MAX(
    a,b)  
Discussion

@def SNMP_MAX(a, b) Computers the maximum of a and b.


SNMP_MIN


#define SNMP_MIN(
    a,b)  
Discussion

@def SNMP_MIN(a, b) Computers the minimum of a and b.


SNMP_SWIPE_MEM


#define SNMP_SWIPE_MEM(
    n,s) do {
    if (
    n) free((
    void *)n); n = s; s=NULL; 
} while(
    0) 
Discussion

@def SNMP_SWIPE_MEM(n, s) Frees pointer n only if it is !NULL, sets n to s and sets s to NULL


SNMP_ZERO


#define SNMP_ZERO(
    s,l) do {
    if (
    s) memset(
    s, 0, l); 
} while(
    0) 
Discussion

@def SNMP_ZERO(s,l) Zeros l bytes of memory starting at s.


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.
Last Updated: 2006-06-20