In Trump's America, healthcare workers carry garbage bags to protect themselves. Aren't you ashamed?

Hospitals are responsible for their PPE. Governors are responsible for the readiness of their states. The CDC provides guidelines for healthcare workers. Governor Cuomo of New York should take some responsibility for the terrible health conditions in his state, rather than blaming others.

The news that the pandemic was coming was public information. Everyone got the same information. It was never a secret. Stupid people act like Trump is the only responsible person. Every member of the authority should equally share responsibility.

Garbage Collection – In which data structure all elements are deleted when all pointers to the keys are no longer available

Stack Exchange network

The Stack Exchange network consists of 175 Q&A communities, including Stack Overflow, the largest and most trusted online community, where developers can learn, share their knowledge, and build their careers.

Visit Stack Exchange

Garbage collection – How is canonical compression performed on a newly counted heap?

The only way I know is to copy the entire heap by assigning copies of all objects on a new heap and deleting the old one, as is the case with couchbase db, for example. You could probably do the same for a subset of the heap to copy less data each time. Google doesn't help me much since it's all about heap compression in gc. Are there other ways to do this?

c – Assignment of values ​​in a 2D array with malloc, prints the garbage in the final array

Enter image description here

I want to create a raster dataset by calculating the average of each pixel for 14 images. The pictures are 10980 * 10980 and a total of 14.

The main program is:

//Main program
int main()
{
    char path(100);
    char suffix(100);

    printf("Enter path to list files: ");
    scanf("%s", path);
    printf("Enter the wildcard: ");
    scanf("%s", suffix);

    struct Node *B02;
    B02 = NULL;
    struct Node *SCL;
    SCL = NULL;
    B02 = recurList(path, suffix);
    printf("Printing B02_head!n");
    show(B02);
    char *suffix_scl = "SCL_10m.tif";
    SCL = recurListSCL(path, suffix_scl);
    printf("Printing files in SCL head:n");
    show(SCL);
    int B02_length = 0;
    int SCL_length = 0;
    B02_length = getCount(B02);
    SCL_length = getCount(SCL);
    printf("BO2 of length: %dn", B02_length);
    printf("SCL of length: %dn", SCL_length);

    struct Node* p;
    p = B02 ->next;

    struct Node *s;
    s = SCL ->next;
    int counter = 1;
    int n_imgs;
    n_imgs = B02_length;
    float *l(n_imgs);
    float *scl_l(n_imgs);
    char *out = "B02_avg.tif";
    int nX;
    int nY;
    GDALAllRegister();
    GDALDatasetH hD(n_imgs);
    GDALDatasetH slcD(n_imgs);
    GDALDriverH hDr(n_imgs);
    GDALDriverH sclDr(n_imgs);
    GDALRasterBandH hB(n_imgs);
    GDALRasterBandH sclB(n_imgs);
    for(int i=0; idata);
        hD(i) = GDALOpen(B02->data, GA_ReadOnly);
        slcD(i) = GDALOpen(SCL->data, GA_ReadOnly);
        hDr(i) = GDALGetDatasetDriver(hD(i));
        sclDr(i) = GDALGetDatasetDriver(slcD(i));
        hB(i) = GDALGetRasterBand(hD(i),1);
        sclB(i) = GDALGetRasterBand(slcD(i),1);
        int nX = GDALGetRasterBandXSize(hB(0));
        l(i) = (float *) malloc(sizeof(float)*nX);
        scl_l(i) = (float *) malloc(sizeof(float)*nX);
        B02=B02->next;
        SCL=SCL->next;
    }
    nX =GDALGetRasterBandXSize(hB(1));
    nY = GDALGetRasterBandYSize(hB(0));
    //int N = nX*nY;
    // Creating output file
    //hD(n_imgs) = GDALCreateCopy(hDr(0), out, hD(0),FALSE,NULL,NULL,NULL);
    //hB(n_imgs) = GDALGetRasterBand(hD(n_imgs),1);
    //l(n_imgs) = (float *) malloc(sizeof(float)*nX);
    //scl_l(n_imgs) = (float *) malloc(sizeof(float)*nX);
    //Accessing the data rowxrow

    printf("Checking the value of keeper.n");
    printf("%sn", B02->data);
    printf("pointern");
    printf("%sn", p->data);

    int nrows = n_imgs;
    int ncols = nX;

    int (*arr)(ncols) = malloc(sizeof(int(nrows)(ncols)));

    int (*arr_scl)(ncols) = malloc(sizeof(int(nrows)(ncols)));

    if(arr == NULL || arr_scl == NULL) {
        printf("malloc failed to allocate memoryn");
    }

    for(int row=0;row<1;row++){
        float *out_line;
        out_line= (float *) malloc(sizeof(float)*nX);
        float *mask_count;
        mask_count = (float*) malloc(sizeof(float)*nX);
        float *avg_line;
        avg_line = (float *) malloc(sizeof(float)*nX);
        int n_null_pix;
        n_null_pix = 0;
        for (int i = 0;idata, GA_ReadOnly);
            scl_raster = GDALOpen( s->data, GA_ReadOnly);
            GDALRasterBandH raster_band;
            GDALRasterBandH scl_band;
            raster_band = GDALGetRasterBand(raster, 1);
            scl_band = GDALGetRasterBand(scl_raster,1);
            float *line;
            float *line_scl;

            int value;
            int mask;

            line = (float *) CPLMalloc(sizeof(float)*nX);
            line_scl = (float*) CPLMalloc(sizeof(float)*nX);

            GDALRasterIO(raster_band, GF_Read,0, row, nXSize,1, line, nXSize, 1, GDT_Float32, 0, 0);
            GDALRasterIO(scl_band, GF_Read, 0, row, nXSize, 1, line_scl, nXSize, 1, GDT_Float32, 0, 0);

            for(int col=0;col)n", value, i, row,col);
                    out_line(col) += value;
                    mask_count(col) += 0;
                    printf("n_imgs:%d, col:%dn", i, col);
                    arr(n_imgs)(col) = value;
                    arr_scl(n_imgs)(col) += 0;
                    }
                else
                    {
                    printf("val:%d::imgID:%d::COOR(<%d,%d>)n", value, i, row,col);
                    out_line(col) += value;
                    mask_count(col) += 1;
                    printf("n_imgs:%d, col:%dn", i, col);
                    arr(n_imgs)(col) = value;
                    arr_scl(n_imgs)(col) += 1;
                    }
            }
            CPLFree(line);
            CPLFree(line_scl);
            p = p->next;
            s = s->next;
            }

        for(int i = 0; i 

Basically, I'm just doing a run for the first line, then the program iterates over pictures and reads the first line of each one of them, then iterates over each cell (column). It checks to see if the pixel is valid or invalid according to the scene classification level value at this point (for Sentinel 2 images, the one created by Sen2Cor is used and for a spatial resolution of 10 m, the suffix SCL_10m.tif is used).

The program seems to work fine, but when I iterate over the values ​​of the 2D array that was created by inserting the values ​​in the previous iteration, the following prints:

ow:8,col:7687,val:21627268,scl_value:24641956
row:8,col:7688,val:20644165,scl_value:22020460
row:8,col:7689,val:21823802,scl_value:22479242
row:8,col:7690,val:24445275,scl_value:21234000
row:8,col:7691,val:26214788,scl_value:20775181
row:8,col:7692,val:29622700,scl_value:23331173
row:8,col:7693,val:25690522,scl_value:23134527
row:8,col:7694,val:23396720,scl_value:17301832
row:8,col:7695,val:25297263,scl_value:11534546
row:8,col:7696,val:23789927,scl_value:19988757
row:8,col:7697,val:23265646,scl_value:25756023

These values ​​apply to the iteration over the 2D array


        for(int i = 0; i 

I do not know, it seems that the initial value in declaring the 2D array that contains the values ​​I get from the first line of each image is the garbage that came from the memory that was in that location.

I do not know if my approach should use that calloc Function instead of malloc in

int (*arr)(ncols) = malloc(sizeof(int(nrows)(ncols)));

The rest of the code from which I can retrieve the list of raster files by extension is here:

#include 
#include 
#include 
#include 
#include "gdal/gdal.h"
#include "gdal/cpl_conv.h"
#include 
#include 
#include 
#include 
#include
#include "gdal/gdal.h"
#include "gdal/cpl_conv.h"

int const nYSize = 10980, nXSize = 10980;

//Node Structure for Linked-List
struct Node 
{
    char *data;
    struct Node *next;
};

//Declaring global variables
struct Node *B02_list = NULL;
struct Node *SCL_list = NULL;


// Function to replace a string with another 
// string 
char* str_replace(char* string, const char* substr, const char* replacement) {
    char* tok = NULL;
    char* newstr = NULL;
    char* oldstr = NULL;
    int   oldstr_len = 0;
    int   substr_len = 0;
    int   replacement_len = 0;

    newstr = strdup(string);
    substr_len = strlen(substr);
    replacement_len = strlen(replacement);

    if (substr == NULL || replacement == NULL) {
        return newstr;
    }

    while ((tok = strstr(newstr, substr))) {
        oldstr = newstr;
        oldstr_len = strlen(oldstr);
        newstr = (char*)malloc(sizeof(char) * (oldstr_len - substr_len + replacement_len + 1));

        if (newstr == NULL) {
            free(oldstr);
            return NULL;
        }

        memcpy(newstr, oldstr, tok - oldstr);
        memcpy(newstr + (tok - oldstr), replacement, replacement_len);
        memcpy(newstr + (tok - oldstr) + replacement_len, tok + substr_len, oldstr_len - substr_len - (tok - oldstr));
        memset(newstr + oldstr_len - substr_len + replacement_len, 0, 1);

        free(oldstr);
    }

    free(string);

    return newstr;
}


//Function to insert a node into a Linked-List
struct Node *insert(struct Node *Head, char *value)
{
    struct Node *new_string;
    new_string = (struct Node *)malloc(sizeof(struct Node));
    new_string->data = malloc(strlen(value)+1);
    strcpy(new_string->data,value);
    struct Node *temp;
    temp = (struct Node*)malloc(sizeof(struct Node));

    if (Head == NULL)
    {
        temp -> data = new_string->data;
        Head = temp;
        Head -> next = Head;
    }
    else
    {
        temp ->data = new_string->data;
        temp ->next = Head ->next;
        Head -> next = temp;
    }

    return Head;

}


//Function to check if a string finishes with a suffix
int string_ends_with(const char * str, const char * suffix)
{
    int str_len = strlen(str);
    int suffix_len = strlen(suffix);

    return 
        (str_len >= suffix_len) &&
        (0 == strcmp(str + (str_len-suffix_len), suffix));
}


//Function to show the elements of the Linked-List
void show(struct Node *Head)
{
    struct Node *ptr;

    if (Head == NULL)
    {
        printf("List is empty.!");
        return;
    }

    ptr = Head ->next;
    do
    {
        printf("%sn", ptr->data);
        ptr = ptr->next;
    } while (ptr != Head->next);

}


//Function to find the files in a directory based on a wildcard
struct Node * recurList(char *basePath, char *suffix)
{
    char path(1000);
    struct dirent *dp;

    DIR *dir = opendir(basePath);
    while ((dp = readdir(dir)) != NULL)
    {
        if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0)
        {
            strcpy(path, basePath);
            strcat(path, "/");
           strcat(path, dp->d_name);

        struct stat s;
            if (stat(path, &s) == 0)
            {
                if( s.st_mode & S_IFDIR )
                {
                recurList(path, suffix);
                }
                else if(s.st_mode &S_IFREG)
                {
                if (string_ends_with(path, suffix))
                    {
                    B02_list = insert(B02_list, path);
                    }
                }
            } 
        }
    }
    return B02_list;
    closedir(dir);
}


//Function to find the SCL files in a directory 
struct Node * recurListSCL(char *basePath, char *suffix)
{
    char path(1000);
    struct dirent *dp;

    DIR *dir = opendir(basePath);
    while ((dp = readdir(dir)) != NULL)
    {
        if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0)
        {
            strcpy(path, basePath);
            strcat(path, "/");
           strcat(path, dp->d_name);

        struct stat s;
            if (stat(path, &s) == 0)
            {
                if( s.st_mode & S_IFDIR )
                {
                recurListSCL(path, suffix);
                }
                else if(s.st_mode &S_IFREG)
                {
                if (string_ends_with(path, suffix))
                    SCL_list = insert(SCL_list, path);
                }
            } 
        }
    }
    return SCL_list;
    closedir(dir);
}


//Function that counts the number of nodes in a linked-list
int getCount(struct Node* head)
{
    int count = 0;
    struct Node* p;
    p = head ->next;
    do
    {
        printf("%sn", p->data);
        p = p->next;
        count++;
    } while (p != head->next);

    return count;
}

Can someone help me to clarify this point? Why can not I print plausible values ​​in my 2D array and what type of array assignment function (malloc or calloc) should I use?

instance – Flask temp files garbage collection

My Flask app includes an image analysis wizard. The user uploads a (typically 32 MB) image, the app performs an analysis of the image based on the parameters specified by the user, sends the result back, and then the user can use further steps of the wizard to perform further analysis.

The image is uploaded only once in the first wizard step and saved in the instance folder. Once the user has reached the last step of the wizard, the image is deleted from the instance folder.

Obviously, there may be many reasons why the user does not complete the wizard (they navigate away, lose communication, etc.), and so I can accumulate many very large files on the server.

I can write a process that runs on a regular basis and deletes files older than n minutes, but there's a better way to handle this (besides re-uploading the image for each wizard step, which would be unacceptable to users).

Beginner – C Garbage Heap aka simplest storage management tool

The idea is to initiate garbage piles at the beginning of main, use gmalloc. gcalloc and grealloc Wrapper and release all allocated memory at the end of main. It helps to avoid memory leaks when writing programs for Ejudge systems. I'd like to get general feedback on the idea and suggestions for improving the code (beginner in C).

Main c

/*
Example of usage of garbage heap.
No free() call but no memory leak.
*/

#include "garbage_heap.h"


int main() {
    init_garbage_heap();
    for (int i = 0; i < 1000; ++i)
    {
        char* str = gmalloc(1000*sizeof(char));
        str = grealloc(str, 2000*sizeof(char));
    }
    free_garbage_heap();
    return 0;
}

garbage_heap.h

#ifndef GARBAGE_HEAP_H
#define GARBAGE_HEAP_H

#include 

void init_garbage_heap (void);
void free_garbage_heap (void);
void* gmalloc (size_t sizemem);
void* gcalloc (size_t number, size_t size);
void* grealloc (void* ptrmem, size_t sizemem);

#endif // GARBAGE_HEAP_H

garbage_heap.c

#include 

#include "garbage_heap.h"


typedef struct
{
    void** buffer;
    int len;
    int capacity;
}
GarbageHeap;


static GarbageHeap garbage_heap;


void init_garbage_heap(void)
{
    int len = 32;
    garbage_heap.len = 0;
    garbage_heap.capacity = len;
    garbage_heap.buffer = (void**)malloc(sizeof(void*)*len);
    for (int i = 0; i < len; ++i)
        garbage_heap.buffer(i) = NULL;
}


void free_garbage_heap(void)
{
    for (int i = 0; i < garbage_heap.len; ++i)
        if (garbage_heap.buffer(i) != NULL)
            free(garbage_heap.buffer(i));
    free(garbage_heap.buffer);
}


void resize_garbage_heap(void)
{
    garbage_heap.capacity *= 2;
    garbage_heap.buffer = (void**)realloc(garbage_heap.buffer, sizeof(void*) * garbage_heap.capacity);
    for (int i = garbage_heap.len; i < garbage_heap.capacity; ++i)
        garbage_heap.buffer(i) = NULL;
}


void* gmalloc(size_t sizemem)
{
    if (garbage_heap.len == garbage_heap.capacity)
        resize_garbage_heap();
    garbage_heap.buffer(garbage_heap.len) = malloc(sizemem);
    ++garbage_heap.len;
    return garbage_heap.buffer(garbage_heap.len - 1);
}


void* gcalloc(size_t number, size_t size)
{
    if (garbage_heap.len == garbage_heap.capacity)
        resize_garbage_heap();
    garbage_heap.buffer(garbage_heap.len) = calloc(number, size);
    ++garbage_heap.len;
    return garbage_heap.buffer(garbage_heap.len - 1);
}


void* grealloc(void* ptrmem, size_t sizemem)
{
    if (ptrmem == NULL)
        return gmalloc(sizemem);
    int i = 0;
    while (garbage_heap.buffer(i) != ptrmem)
        ++i;
    void* tmp_ptr = realloc(ptrmem, sizemem);
    if (tmp_ptr != NULL)
        garbage_heap.buffer(i) = tmp_ptr;
    return tmp_ptr;
}

The decryption function returns garbage data

I have the question How do I decrypt a column in SQL Server that was encrypted with .NET code, and I was able to register and use the feature in SQL Server Management Studio. The problem is that the decrypted data is garbage. Here is the output:

Enter image description here

In a .NET console app, the same code works fine.
Here is my SQL statement:

SELECT FieldName, dbo.SLWSDecrypt (FieldName, CONVERT (VARBINARY (32), & # 39; 0x711C69CF751C3BBBC204AFD2C7CDFE2E751321CA8AC11856A5D67123D478FG1 & # 39 ;, 1))
FROM CaseData