Advertisement
Guest User

Untitled

a guest
May 6th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. PyTypeObject *type;
  2. DotStarObject *self = NULL;
  3. (...)
  4. // Allocate space for LED data:
  5. if((!n_pixels) || ((pixels = (uint8_t *)malloc(n_pixels * 4)))) {
  6. if((self = (DotStarObject *)type->tp_alloc(type, 0))) {
  7. self->numLEDs = n_pixels;
  8. self->dataMask = 0;
  9. self->clockMask = 0;
  10. self->bitrate = bitrate;
  11. self->fd = -1;
  12. self->pixels = pixels; // NULL if 0 pixels
  13. self->pBuf = NULL; // alloc'd on 1st use
  14. self->dataPin = dPin;
  15. self->clockPin = cPin;
  16. self->brightness = 0;
  17. self->rOffset = rOffset;
  18. self->gOffset = gOffset;
  19. self->bOffset = bOffset;
  20. Py_INCREF(self);
  21. } else if(pixels) {
  22. free(pixels);
  23. }
  24. }
  25.  
  26. DotStarObject *self = (DotStarObject*)malloc(sizeof(DotStarObject));
  27. (...)
  28. if((!n_pixels) || ((pixels = (uint8_t *)malloc(n_pixels * 4)))) {
  29. self->numLEDs = n_pixels;
  30. self->dataMask = 0;
  31. self->clockMask = 0;
  32. self->bitrate = bitrate;
  33. self->fd = -1;
  34. self->pixels = pixels; // NULL if 0 pixels
  35. self->pBuf = NULL; // alloc'd on 1st use
  36. self->dataPin = dPin;
  37. self->clockPin = cPin;
  38. self->brightness = 0;
  39. self->rOffset = rOffset;
  40. self->gOffset = gOffset;
  41. self->bOffset = bOffset;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement