FreeBSD/sys/dev/ofw/openfirm.c
/*
 * Store the value of a property of a package into newly allocated memory
 * (using the M_OFWPROP malloc pool and M_WAITOK).  elsz is the size of a
 * single element, the number of elements is return in number.
 */
Store the value of a property of a package into newly allocated memory
(using the M_OFWPROP malloc pool and M_WAITOK).  elsz is the size of a
single element, the number of elements is return in number.
Store the value of a property of a package into newly allocated memory ( using the M_OFWPROP malloc pool and M_WAITOK ) . elsz is the size of a single element the number of elements is return in number .
ssize_t
OF_getprop_alloc(phandle_t package, const char *propname, int elsz, void **buf)
{
	int len;
	*buf = NULL;
	if ((len = OF_getproplen(package, propname)) == -1 ||
	    len % elsz != 0)
		return (-1);
	*buf = malloc(len, M_OFWPROP, M_WAITOK);
	if (OF_getprop(package, propname, *buf, len) == -1) {
		free(*buf, M_OFWPROP);
		*buf = NULL;
		return (-1);
	}
	return (len / elsz);
}
ssize_t OF_getprop_alloc ( phandle_t package , const char * propname , int elsz , void * * buf ) { int len ; * buf = NULL ; if ( ( len = OF_getproplen ( package , propname ) ) == -1 || len % elsz != 0 ) return ( -1 ) ; * buf = malloc ( len , M_OFWPROP , M_WAITOK ) ; if ( OF_getprop ( package , propname , * buf , len ) == -1 ) { free ( * buf , M_OFWPROP ) ; * buf = NULL ; return ( -1 ) ; } return ( len / elsz ) ; }
Store the value of a property of a package into newly allocated memory
 (using the M_OFWPROP malloc pool and M_WAITOK).
Store the value of a property of a package into newly allocated memory ( using the M_OFWPROP malloc pool and M_WAITOK ) .