src/video/SDL_video.c
changeset 7046 8d5636aafd1c
parent 7037 3fedf1f25b94
child 7089 257fc4e541e1
child 8460 f483e8bdae3c
equal deleted inserted replaced
7045:4be2c24b7de1 7046:8d5636aafd1c
  1423 SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
  1423 SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata)
  1424 {
  1424 {
  1425     SDL_WindowUserData *prev, *data;
  1425     SDL_WindowUserData *prev, *data;
  1426 
  1426 
  1427     CHECK_WINDOW_MAGIC(window, NULL);
  1427     CHECK_WINDOW_MAGIC(window, NULL);
       
  1428     
       
  1429     /* Input validation */
       
  1430     if (name == NULL || SDL_strlen(name) == 0) {
       
  1431       SDL_InvalidParamError("name");
       
  1432       return NULL;
       
  1433     }
  1428 
  1434 
  1429     /* See if the named data already exists */
  1435     /* See if the named data already exists */
  1430     prev = NULL;
  1436     prev = NULL;
  1431     for (data = window->data; data; prev = data, data = data->next) {
  1437     for (data = window->data; data; prev = data, data = data->next) {
  1432         if (SDL_strcmp(data->name, name) == 0) {
  1438         if (data->name && SDL_strcmp(data->name, name) == 0) {
  1433             void *last_value = data->data;
  1439             void *last_value = data->data;
  1434 
  1440 
  1435             if (userdata) {
  1441             if (userdata) {
  1436                 /* Set the new value */
  1442                 /* Set the new value */
  1437                 data->data = userdata;
  1443                 data->data = userdata;
  1465 {
  1471 {
  1466     SDL_WindowUserData *data;
  1472     SDL_WindowUserData *data;
  1467 
  1473 
  1468     CHECK_WINDOW_MAGIC(window, NULL);
  1474     CHECK_WINDOW_MAGIC(window, NULL);
  1469 
  1475 
       
  1476     /* Input validation */
       
  1477     if (name == NULL || SDL_strlen(name) == 0) {
       
  1478       SDL_InvalidParamError("name");
       
  1479       return NULL;
       
  1480     }
       
  1481 
  1470     for (data = window->data; data; data = data->next) {
  1482     for (data = window->data; data; data = data->next) {
  1471         if (SDL_strcmp(data->name, name) == 0) {
  1483         if (data->name && SDL_strcmp(data->name, name) == 0) {
  1472             return data->data;
  1484             return data->data;
  1473         }
  1485         }
  1474     }
  1486     }
  1475     return NULL;
  1487     return NULL;
  1476 }
  1488 }