Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PyTypeObject *type;
- DotStarObject *self = NULL;
- (...)
- // Allocate space for LED data:
- if((!n_pixels) || ((pixels = (uint8_t *)malloc(n_pixels * 4)))) {
- if((self = (DotStarObject *)type->tp_alloc(type, 0))) {
- self->numLEDs = n_pixels;
- self->dataMask = 0;
- self->clockMask = 0;
- self->bitrate = bitrate;
- self->fd = -1;
- self->pixels = pixels; // NULL if 0 pixels
- self->pBuf = NULL; // alloc'd on 1st use
- self->dataPin = dPin;
- self->clockPin = cPin;
- self->brightness = 0;
- self->rOffset = rOffset;
- self->gOffset = gOffset;
- self->bOffset = bOffset;
- Py_INCREF(self);
- } else if(pixels) {
- free(pixels);
- }
- }
- DotStarObject *self = (DotStarObject*)malloc(sizeof(DotStarObject));
- (...)
- if((!n_pixels) || ((pixels = (uint8_t *)malloc(n_pixels * 4)))) {
- self->numLEDs = n_pixels;
- self->dataMask = 0;
- self->clockMask = 0;
- self->bitrate = bitrate;
- self->fd = -1;
- self->pixels = pixels; // NULL if 0 pixels
- self->pBuf = NULL; // alloc'd on 1st use
- self->dataPin = dPin;
- self->clockPin = cPin;
- self->brightness = 0;
- self->rOffset = rOffset;
- self->gOffset = gOffset;
- self->bOffset = bOffset;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement