Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature-vt/sys/src/libmp/port/mptole.c – Rev 33

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include "os.h"
2
#include <mp.h>
3
#include "dat.h"
4
 
5
// convert an mpint into a little endian byte array (least significant byte first)
6
//   return number of bytes converted
7
//   if p == nil, allocate and result array
8
int
9
mptole(mpint *b, uchar *p, uint n, uchar **pp)
10
{
33 7u83 11
	int m;
2 - 12
 
33 7u83 13
	m = (mpsignif(b)+7)/8;
14
	if(m == 0)
15
		m++;
2 - 16
	if(p == nil){
33 7u83 17
		n = m;
2 - 18
		p = malloc(n);
33 7u83 19
		if(p == nil)
20
			sysfatal("mptole: %r");
21
		setmalloctag(p, getcallerpc(&b));
22
	} else if(n < m)
23
		return -1;
2 - 24
	if(pp != nil)
25
		*pp = p;
33 7u83 26
	mptolel(b, p, n);
27
	return m;
2 - 28
}