Lines 407-412
Link Here
|
407 |
#endif |
407 |
#endif |
408 |
|
408 |
|
409 |
/** |
409 |
/** |
|
|
410 |
* Read a 8-bit value beginning at <b>cp</b>. Equivalent to |
411 |
* *(uint8_t*)(cp), but will not cause segfaults on platforms that forbid |
412 |
* unaligned memory access. (fmccor@gentoo.org) |
413 |
*/ |
414 |
uint8_t |
415 |
get_uint8(const char *cp) |
416 |
{ |
417 |
uint8_t v; |
418 |
memcpy(&v,cp,1); |
419 |
return v; |
420 |
} |
421 |
/** |
410 |
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to |
422 |
* Read a 16-bit value beginning at <b>cp</b>. Equivalent to |
411 |
* *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid |
423 |
* *(uint16_t*)(cp), but will not cause segfaults on platforms that forbid |
412 |
* unaligned memory access. |
424 |
* unaligned memory access. |
Lines 431-436
Link Here
|
431 |
return v; |
443 |
return v; |
432 |
} |
444 |
} |
433 |
/** |
445 |
/** |
|
|
446 |
* Set a 8-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to |
447 |
* *(uint8_t)(cp) = v, but will not cause segfaults on platforms that forbid |
448 |
* unaligned memory access. (fmccor@gentoo.org) */ |
449 |
void |
450 |
set_uint8(char *cp, uint8_t v) |
451 |
{ |
452 |
memcpy(cp,&v,1); |
453 |
} |
454 |
/** |
434 |
* Set a 16-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to |
455 |
* Set a 16-bit value beginning at <b>cp</b> to <b>v</b>. Equivalent to |
435 |
* *(uint16_t)(cp) = v, but will not cause segfaults on platforms that forbid |
456 |
* *(uint16_t)(cp) = v, but will not cause segfaults on platforms that forbid |
436 |
* unaligned memory access. */ |
457 |
* unaligned memory access. */ |