(from agent/mibgroup/ucd-snmp/lmSensors.c -simplified for readability)

typedef struct {
char            name[MAX_NAME];
int             value;
} _sensor;

typedef struct {
int             n;

_sensor*        sensor;
size_t          current_len;

} _sensor_array;
 
for (i = 0; i < N_TYPES; i++){

/* Malloc the default number of sensors. */
sensor_array[i].sensor = (_sensor*)malloc(sizeof(_sensor) *
DEFAULT_SENSORS);
}

###############


If you're going to malloc everything right away, why not just use an array
and skip the pointers.

(Yes, I know it's a dumb question - the janitor's complaining about the
forehead-sized holes in the walls.)
-- 

This communication is intended for the use of the recipient to which it is
addressed, and may contain confidential, personal and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take action
relying on it. Any communication received in error, or subsequent reply,
should be deleted or destroyed.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to