[c23,rdtk] replace NULL with nullptr

This commit is contained in:
Armin Novak
2026-02-26 14:00:32 +01:00
parent 402ea0ea0f
commit 8007f3c291
9 changed files with 53 additions and 53 deletions

View File

@@ -93,7 +93,7 @@ rdtkButton* rdtk_button_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
rdtkButton* button = (rdtkButton*)calloc(1, sizeof(rdtkButton));
if (!button)
return NULL;
return nullptr;
button->engine = engine;
button->ninePatch = ninePatch;
@@ -127,7 +127,7 @@ int rdtk_button_engine_uninit(rdtkEngine* engine)
if (engine->button)
{
rdtk_button_free(engine->button);
engine->button = NULL;
engine->button = nullptr;
}
return 1;

View File

@@ -32,7 +32,7 @@ rdtkEngine* rdtk_engine_new(void)
rdtkEngine* engine = (rdtkEngine*)calloc(1, sizeof(rdtkEngine));
if (!engine)
return NULL;
return nullptr;
if (rdtk_font_engine_init(engine) < 0)
goto fail;
@@ -47,7 +47,7 @@ rdtkEngine* rdtk_engine_new(void)
fail:
rdtk_engine_free(engine);
return NULL;
return nullptr;
}
void rdtk_engine_free(rdtkEngine* engine)

View File

@@ -165,7 +165,7 @@ static char* rdtk_font_load_descriptor_file(const char* filename, size_t* pSize)
FILE* fp = winpr_fopen(filename, "r");
if (!fp)
return NULL;
return nullptr;
if (_fseeki64(fp, 0, SEEK_END) != 0)
goto fail;
@@ -194,7 +194,7 @@ static char* rdtk_font_load_descriptor_file(const char* filename, size_t* pSize)
if (readSize < 1)
{
free(buffer);
return NULL;
return nullptr;
}
}
@@ -206,7 +206,7 @@ static char* rdtk_font_load_descriptor_file(const char* filename, size_t* pSize)
fail:
(void)fclose(fp);
return NULL;
return nullptr;
}
WINPR_ATTR_NODISCARD
@@ -294,7 +294,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
*q = '\0';
errno = 0;
{
long val = strtol(p, NULL, 0);
long val = strtol(p, nullptr, 0);
if ((errno != 0) || (val == 0) || (val > UINT32_MAX))
goto fail;
@@ -346,7 +346,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
*q = '\0';
errno = 0;
{
const unsigned long val = strtoul(p, NULL, 0);
const unsigned long val = strtoul(p, nullptr, 0);
if ((errno != 0) || (val > UINT16_MAX))
goto fail;
@@ -413,7 +413,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
goto fail;
font->glyphCount = (uint16_t)count;
font->glyphs = NULL;
font->glyphs = nullptr;
if (count > 0)
font->glyphs = (rdtkGlyph*)calloc(font->glyphCount, sizeof(rdtkGlyph));
@@ -461,7 +461,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
*q = '\0';
errno = 0;
{
long val = strtol(p, NULL, 0);
long val = strtol(p, nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -502,7 +502,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
tok[1] = p + 1;
errno = 0;
{
long val = strtol(tok[0], NULL, 0);
long val = strtol(tok[0], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -510,7 +510,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
glyph->offsetX = (INT32)val;
}
{
long val = strtol(tok[1], NULL, 0);
long val = strtol(tok[1], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -559,7 +559,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
tok[3] = p + 1;
errno = 0;
{
long val = strtol(tok[0], NULL, 0);
long val = strtol(tok[0], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -567,7 +567,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
glyph->rectX = (INT32)val;
}
{
long val = strtol(tok[1], NULL, 0);
long val = strtol(tok[1], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -575,7 +575,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
glyph->rectY = (INT32)val;
}
{
long val = strtol(tok[2], NULL, 0);
long val = strtol(tok[2], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -583,7 +583,7 @@ static int rdtk_font_parse_descriptor_buffer(rdtkFont* font, char* buffer,
glyph->rectWidth = (INT32)val;
}
{
long val = strtol(tok[3], NULL, 0);
long val = strtol(tok[3], nullptr, 0);
if ((errno != 0) || (val < INT32_MIN) || (val > INT32_MAX))
goto fail;
@@ -644,9 +644,9 @@ static int rdtk_font_load_descriptor(rdtkFont* font, const char* filename)
rdtkFont* rdtk_font_new(rdtkEngine* engine, const char* path, const char* file)
{
size_t length = 0;
rdtkFont* font = NULL;
char* fontImageFile = NULL;
char* fontDescriptorFile = NULL;
rdtkFont* font = nullptr;
char* fontImageFile = nullptr;
char* fontDescriptorFile = nullptr;
WINPR_ASSERT(engine);
WINPR_ASSERT(path);
@@ -703,7 +703,7 @@ cleanup:
free(fontDescriptorFile);
rdtk_font_free(font);
return NULL;
return nullptr;
}
WINPR_ATTR_MALLOC(rdtk_font_free, 1)
@@ -719,7 +719,7 @@ static rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, const uint8_t* image
rdtkFont* font = (rdtkFont*)calloc(1, sizeof(rdtkFont));
if (!font)
return NULL;
return nullptr;
font->engine = engine;
font->image = winpr_image_new();
@@ -727,7 +727,7 @@ static rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, const uint8_t* image
if (!font->image)
{
free(font);
return NULL;
return nullptr;
}
const int status = winpr_image_read_buffer(font->image, imageData, imageSize);
@@ -735,7 +735,7 @@ static rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, const uint8_t* image
{
winpr_image_free(font->image, TRUE);
free(font);
return NULL;
return nullptr;
}
size = descriptorSize;
@@ -755,7 +755,7 @@ static rdtkFont* rdtk_embedded_font_new(rdtkEngine* engine, const uint8_t* image
fail:
rdtk_font_free(font);
return NULL;
return nullptr;
}
void rdtk_font_free(rdtkFont* font)
@@ -774,8 +774,8 @@ int rdtk_font_engine_init(rdtkEngine* engine)
WINPR_ASSERT(engine);
if (!engine->font)
{
const uint8_t* imageData = NULL;
const uint8_t* descriptorData = NULL;
const uint8_t* imageData = nullptr;
const uint8_t* descriptorData = nullptr;
const SSIZE_T imageSize =
rdtk_get_embedded_resource_file("source_serif_pro_regular_12." FILE_EXT, &imageData);
const SSIZE_T descriptorSize =
@@ -799,7 +799,7 @@ int rdtk_font_engine_uninit(rdtkEngine* engine)
if (engine->font)
{
rdtk_font_free(engine->font);
engine->font = NULL;
engine->font = nullptr;
}
return 1;

View File

@@ -67,7 +67,7 @@ rdtkLabel* rdtk_label_new(rdtkEngine* engine)
rdtkLabel* label = (rdtkLabel*)calloc(1, sizeof(rdtkLabel));
if (!label)
return NULL;
return nullptr;
label->engine = engine;
@@ -96,7 +96,7 @@ int rdtk_label_engine_uninit(rdtkEngine* engine)
if (engine->label)
{
rdtk_label_free(engine->label);
engine->label = NULL;
engine->label = nullptr;
}
return 1;

View File

@@ -494,7 +494,7 @@ rdtkNinePatch* rdtk_nine_patch_new(rdtkEngine* engine)
rdtkNinePatch* ninePatch = (rdtkNinePatch*)calloc(1, sizeof(rdtkNinePatch));
if (!ninePatch)
return NULL;
return nullptr;
ninePatch->engine = engine;
return ninePatch;
@@ -512,7 +512,7 @@ void rdtk_nine_patch_free(rdtkNinePatch* ninePatch)
int rdtk_nine_patch_engine_init(rdtkEngine* engine)
{
int status = 0;
rdtkNinePatch* ninePatch = NULL;
rdtkNinePatch* ninePatch = nullptr;
WINPR_ASSERT(engine);
@@ -520,8 +520,8 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
{
SSIZE_T size = 0;
const uint8_t* data = NULL;
wImage* image = NULL;
const uint8_t* data = nullptr;
wImage* image = nullptr;
status = -1;
size = rdtk_get_embedded_resource_file("btn_default_normal.9." FILE_EXT, &data);
@@ -553,11 +553,11 @@ int rdtk_nine_patch_engine_init(rdtkEngine* engine)
if (!engine->textField9patch)
{
const uint8_t* data = NULL;
const uint8_t* data = nullptr;
status = -1;
const SSIZE_T size =
rdtk_get_embedded_resource_file("textfield_default.9." FILE_EXT, &data);
wImage* image = NULL;
wImage* image = nullptr;
if (size > 0)
{
@@ -593,13 +593,13 @@ int rdtk_nine_patch_engine_uninit(rdtkEngine* engine)
if (engine->button9patch)
{
rdtk_nine_patch_free(engine->button9patch);
engine->button9patch = NULL;
engine->button9patch = nullptr;
}
if (engine->textField9patch)
{
rdtk_nine_patch_free(engine->textField9patch);
engine->textField9patch = NULL;
engine->textField9patch = nullptr;
}
return 1;

View File

@@ -49,7 +49,7 @@ rdtkSurface* rdtk_surface_new(rdtkEngine* engine, uint8_t* data, uint16_t width,
rdtkSurface* surface = (rdtkSurface*)calloc(1, sizeof(rdtkSurface));
if (!surface)
return NULL;
return nullptr;
surface->engine = engine;
@@ -73,7 +73,7 @@ rdtkSurface* rdtk_surface_new(rdtkEngine* engine, uint8_t* data, uint16_t width,
if (!surface->data)
{
free(surface);
return NULL;
return nullptr;
}
surface->owner = true;

View File

@@ -93,7 +93,7 @@ rdtkTextField* rdtk_text_field_new(rdtkEngine* engine, rdtkNinePatch* ninePatch)
rdtkTextField* textField = (rdtkTextField*)calloc(1, sizeof(rdtkTextField));
if (!textField)
return NULL;
return nullptr;
textField->engine = engine;
textField->ninePatch = ninePatch;
@@ -126,7 +126,7 @@ int rdtk_text_field_engine_uninit(rdtkEngine* engine)
if (engine->textField)
{
rdtk_text_field_free(engine->textField);
engine->textField = NULL;
engine->textField = nullptr;
}
return 1;

View File

@@ -6,12 +6,12 @@
int TestRdTkNinePatch(int argc, char* argv[])
{
rdtkEngine* engine = NULL;
rdtkSurface* surface = NULL;
rdtkEngine* engine = nullptr;
rdtkSurface* surface = nullptr;
uint32_t scanline = 0;
uint32_t width = 0;
uint32_t height = 0;
uint8_t* data = NULL;
uint8_t* data = nullptr;
int ret = -1;
WINPR_UNUSED(argc);
@@ -28,14 +28,14 @@ int TestRdTkNinePatch(int argc, char* argv[])
scanline = width * 4;
/* let rdtk allocate the surface buffer */
if (!(surface = rdtk_surface_new(engine, NULL, width, height, scanline)))
if (!(surface = rdtk_surface_new(engine, nullptr, width, height, scanline)))
{
printf("%s: error creating auto-allocated surface (%" PRIu32 ")\n", __func__,
GetLastError());
goto out;
}
rdtk_surface_free(surface);
surface = NULL;
surface = nullptr;
/* test self-allocated buffer */
if (!(data = calloc(height, scanline)))

View File

@@ -35,15 +35,15 @@ int main(int argc, char** argv)
int rc = 1;
int pf_count = 0;
XEvent event;
XImage* image = NULL;
XImage* image = nullptr;
Pixmap pixmap = 0;
Window window = 0;
rdtkSurface* surface = NULL;
rdtkSurface* surface = nullptr;
WINPR_UNUSED(argc);
WINPR_UNUSED(argv);
Display* display = XOpenDisplay(NULL);
Display* display = XOpenDisplay(nullptr);
if (!display)
{
@@ -92,11 +92,11 @@ int main(int argc, char** argv)
if (rdtk_surface_fill(surface, 0, 0, width, height, 0x3BB9FF) < 0)
goto fail;
if (rdtk_label_draw(surface, 16, 16, 128, 32, NULL, "label", 0, 0) < 0)
if (rdtk_label_draw(surface, 16, 16, 128, 32, nullptr, "label", 0, 0) < 0)
goto fail;
if (rdtk_button_draw(surface, 16, 64, 128, 32, NULL, "button") < 0)
if (rdtk_button_draw(surface, 16, 64, 128, 32, nullptr, "button") < 0)
goto fail;
if (rdtk_text_field_draw(surface, 16, 128, 128, 32, NULL, "text field") < 0)
if (rdtk_text_field_draw(surface, 16, 128, 128, 32, nullptr, "text field") < 0)
goto fail;
window = XCreateSimpleWindow(display, root_window, x, y, width, height, 1, border, background);