Μηνιαία αρχεία: Απρίλιος 2017


C/C++: A small tip for freeing dynamic memory

Taking into account the behavior of the free() function, it is a good practice to set your pointer to NULL right after you free it.

By doing so, you can rest assured that in case you accidentally call free() more than one times on the same variable (with no reallocation or reassignment in between), then no bad side-effects will happen (besides any logical issues that your code might be dealing with).

You can include free() from malloc.h and it will have the following signature extern void free(void *__ptr);.

Description of operation:

Free a block allocated by malloc, realloc or calloc.
The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to malloc(), calloc(), or realloc().  Otherwise, if free(ptr) has  already been called before, undefined behavior occurs.  If ptr is NULL, no operation is performed.

Working examples:


#include <stdio.h>
#include <malloc.h>

int main()
{
  printf("Hello, World!\n");

  void * c = malloc (sizeof(char) * 10);

  free(c);
  c = NULL;
  free(c);

  return 0;
}


#include <iostream>

int main()
{
  std::cout << "Hello, World!" << std::endl;

  void * c = malloc (sizeof(char) * 10);

  free(c);
  c = NULL;
  free(c);

  return 0;
}


Select range of lines in Notepad++ using line numbers 13

In response to a question in this post we proposed the following method to select a range of lines in Notepad++ using the line numbers:

  1. Press Ctrl + G, type the start line and hit Enter to go to the start line.
  2. Then go to the menu, click on Edit and then Begin/End select.
  3. Press again Ctrl + G, and type the end line number and hit Enter to go to it.
  4. Back to the menu, click on Edit and then Begin/End select once more.
    By now you will have your range of lines selected.

GNU/Linux: start System Settings from terminal to view error/warning messages

Recently, we tried to understand why creating a hotspot would not work in Fedora 25 with Gnome 3.

Starting the control panel from the GUI (the launcher, or the power cog) did not provide us with the debug messages needed to understand what was going on.
So we needed the command to use that would start the control panel from a a terminal window

For Ubuntu 14.04 and newer, which by default are deployed with Unity, we used:

unity-control-center;

For Ubuntu 13.10 and older versions, which were deployed with Gnome 2, we used:

gnome-control-center;

For Fedora 25 with Gnome 3, we used again:

gnome-control-center;

 


Google Hash Code Final Round live stream and Extended Final Round

Hi everyone!

The Final Round of Hash Code will take place today, Saturday, 1st April and you can watch the tech talks and closing ceremony here. We hope you’ll be able to tune in and watch!

Agenda (Note: The following times are in Cyprus timezone, they are approximate and subject to change.)

  • 19:00 EET – Live stream opens with photo countdown
  • 19:30 EET – Tech talk: Making the Internet more secure with Certificate Transparency
  • 19:45 EET – Tech talk: Managing Content on YouTube…with Neural Networks!
  • 20:00 EET – Tech talk: Techniques and Domains
  • 20:15 EET – Googler Panel
  • 20:45 EET – Awards ceremony

Extended Final Round

The Final Round problem statement and scoreboard will be released in the coming days, so look for the email which will let you know when it’s live. Anyone who registered to compete in Hash Code and formed a team for the Online Qualification Round will be able to download the problem statement and submit solutions to see where they would have stacked up!

Thanks!